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!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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:
[code]


Uploader

Uploader










[/code]


PHP script
[code]
<?php

$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'],
$target_path);

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..";
?>
[/code]

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

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.