I am trying to create a form that allows a user to upload a picture onto my server. The upload itself seems to be working, but it fails when I try to move the temporary file to the new folder... I have been stuck at this step for two days already, would appreciate any help!
1) I made sure the permission of the uploads folder is 777
2) My form is declared like this: <form action="<?php echo $PHP_SELF; ?>" method="post" name="AddTroupeForm" enctype="multipart/form-data">
3) The input box is declared like this: <input type="hidden" name="MAX_FILE_SIZE" value="100000" /><input name="Picture" type="file">
Thank you for any help!
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/c:/hosting/webhost4life/member/mychow/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
A sample output:
Possible file upload attack!
Here is some more debugging info:Array
(
[Picture] => Array
(
[name] => babysitting_2.jpg
[type] => image/jpeg
[tmp_name] => C:\PHP\uploadtemp\phpCE16.tmp
[error] => 0
[size] => 10521
)
)
So it looks like the file is uploaded, but it simply failed at the move_uploaded_file section... 😕