从Android
应用程序中,我将photo
发布到webserver
中。在PHP
脚本中,我想将文件保存在directory
中:
$name = "parcelle_" . $photo->lireBienPhotoSeq() . ".png";
if ( ! file_exists (RP_PHOTO_PARCELLE) ) {
mkdir(RP_PHOTO_PARCELLE, 0777, true);
chmod(RP_PHOTO_PARCELLE, 0777);
}
$dest = DIR_MAIN . '/data/photo_parcelle/' . $name;
$image = base64_decode($_POST["image"]);
$img = imagecreatefromstring($image);
if ($img !== false)
imagepng($img, $dest);
$chemin = PHOTO_PARCELLE . $name;
问题是image
没有创建,Android
应用程序收到响应代码500 (HTTP_INTERNAL_ERROR) !我做了一个ls -l
查看directory
的权限,是0777。
有几件事可能会出错,你的描述不够详细。
如何发布图像?
您确定它是作为POST变量发送的,而不是作为$_FILES中的上传文件发送的吗?
您确定$_POST['image']包含可识别的图像格式(JPEG、PNG、GIF、WBMP和GD2)的内容,而不是类似原始数据的内容吗?
您确定RP_PHOTO_PARCELLE与DIR_MAIN相同吗?‘/数据/photo_parcelle/’吗?
imagecreatefromstring($image)的结果是什么??
查看日志后,imagecreatefromstring
函数是未知的,所以安装了gd包,它可以工作!服务器是新的,不像我的本地电脑!lol