我一直在慢慢学习PHP和发现关于这个问题,并发布其他开发者解决方案的信息的数组。 我试图拥有一个Android应用程序通过HTTP POST文件上传到PHP服务器。 但是有什么不工作对我的服务器端欺骗试图用PHP编写到文件。
这里是PHP代码:
// Where the file is going to be placed
$target_path = "/var/www/media2net/uploads/uploads";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']) .
" has been uploaded";
chmod("uploads/" . basename($_FILES['uploadedfile']['name']), 755);
} else {
echo "There was an error uploading the file, please try again!";
echo "filename: " . basename( $_FILES['uploadedfile']['name']);
echo " target_path: " .$target_path;
}
我已经从客户端检测线鲨鱼知道HTTP POST正确发出去了,我也已确保该目录我写的文件具有正确的权限,以及PHP安全模式设置为关闭。
从Apache2的error.log中文件的输出读取
[Wed Dec 05 09:25:36 2012] [error] [client 74.14.162.250] PHP Warning:
move_uploaded_file(): Unable to move '/tmp/phpVLOnn3' to
'/var/www/media2net/uploads/downloaded_file.png'
in /var/www/media2net/upload.php on line 9
这个问题还是如何进一步排查任何帮助,这将不胜感激。