I've been slowly learning PHP and have found an array of information on the subject and solutions posted by other developers. I am attempting to have an android application upload a file to PHP server via HTTP post. However something is not working on my server side wile attempting to write to file in PHP.
Here is the PHP code:
// 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;
}
I already know from inspecting wire shark on client side that http post is sent out correctly, also I have ensured that the directory I'm writing the file to has the correct permissions, and php safe mode is set to off.
the output from apache2 error.log file reads
[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
Any help with this problem or further ways to trouble shoot this would be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…