我想通过PHP网络服务使用Android应用程序上传图像。图像上传但是 当我想裁剪上传的图像时,它失败了。 file_exixts条件返回true。 同样我在我的网站上尝试过并成功上传和裁剪图像。
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
}
?>
我编辑了我的问题。我在参数中传递完整路径,现在我只通过参数传递图像名称。我帮我错了。提前致谢。
答案 0 :(得分:0)
patermeter变量传递给函数
<?php
function crop_medium($image_name_with_full_path)
{
不是你在函数中使用的。
$resizeObj = new resize("upload/$encrypted_name");