1

我想通过 PHP Web 服务使用 Android 应用程序上传图像。图片正在上传,但是当我想裁剪上传的图片时,它失败了。file_exixts 条件返回真。我在我的网站上尝试过同样的事情,并成功上传和裁剪图像。

include_once('../crop1.php'); // for cropping an image
include_once('../config.php'); // for encrypting the name of the image

header('Content-Type: bitmap; charset=utf-8'); 
$filename = $_REQUEST['photo'];
$binary = base64_decode($filename);
$encrypted_name = name_encrypt($filename); // encrypting the name of the image

$final = "../upload/".$encrypted_name."jpg"; // Its attaching the extension to the image.

$file = fopen($final, 'wb'); // commented the original code

fwrite($file, $binary); // storing image to the folder


if (file_exists($final))  //checking if image exists
{
    crop_medium($encrypted_name.'jpg'); // if image exists then crop it by calling this function in the included file crop1.php
    $query = "INSERT INTO `error_log` (`param1`, `param2`, `date_time`) VALUES ('1', 'success_found', '2013-07-08')";
    $result = mysql_query($query);
} 

$return["status"] = "OK";
$return["message"] = "Uploaded successfully";

echo json_encode($return);
?>

在crop1.php 我有以下代码

<?php
function crop_medium($image_name)
{   
    include_once("resize-class.php"); // calling the php file to resize an uploaded image from the upload folder
    $resizeObj = new resize("upload/$encrypted_name"); 

    $resizeObj -> resizeImage(167, 121, 'crop'); // resizing and image in the given format

    $crop_image = "$encrypted_name";
    $resizeObj -> saveImage("cropped/$crop_image", 100); // saving resized image in other folder
}
?>

我编辑了我的问题。我在参数中传递了完整路径,现在我只通过参数传递图像名称。请帮助我哪里出错了。提前致谢。

4

1 回答 1

0

您传递给函数的参数表变量

<?php
function crop_medium($image_name_with_full_path)
{ 

不是你在函数中使用的。

$resizeObj = new resize("upload/$encrypted_name"); 
于 2013-07-08T11:09:29.733 回答