我正在使用HTTP post将图片上传到服务器,我有以下PHP代码:
$base_path = "";
$target_path = $base_path . basename ( $_FILES ['uploadfile'] ['name'] );
if (move_uploaded_file ( $_FILES ['uploadfile'] ['tmp_name'], $target_path )) {
echo "Good";
} else {
echo "FAIL";
}
我确定图片已上传到temp。但无论如何,我只是无法存储图像文件。我当前的许可是664进行测试。
答案 0 :(得分:0)
您需要将$base_path
变量设置为存储文件的绝对路径。 (即/path/to/your/document/root/image/directory/
)
此外,请确保将要存储图像的目录由apache用户拥有,或者由apache用户(chmod 777)写入。
答案 1 :(得分:0)
试试这个:
Pl check the uploaded path is correct before move the file
&&
Set the folder permission to 777 where you upload the file.
谢谢!