file upload script problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


file upload script problem

Josh CodeJosh Code Posts: 675Member
I have a file submitted to the server but it isn't moving. I hope you can explain why the file might not be moving.

It seems to be uploaded to the server successfully because the file's error code is 0.

The file isn't moving from its temperary location to a new one, though.
The move_uploaded_file function is returning false(indicating that it failed to move the temperary file).

form code:




PHP script

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

echo "target path is $target_path";

$f = $_FILES['uploadedfile']['tmp_name'];
echo "file is $f<br />";
$response = move_uploaded_file($_FILES['uploadedfile']['tmp_name'],

if ($response)
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded
} else{
echo "There was an error uploading the file, please try again!

$e = $_FILES["uploadedfile"]["error"];
echo "error code: $e

echo "hey..";

output from script after submitting a short simple file:
target path is uploads/info.txtfile is /tmp/php4sZB7g
There was an error uploading the file, please try again!
error code: 0

My first guess was that the server was configured improperly for file uploads. Someone in charge of administering the server said the server is configured properly for file uploads with PHP, though. Do you have other ideas?
Sign In or Register to comment.