Home: Other Programming Languages: PHP:
uploading an image



tolearn
Novice

May 1, 2006, 10:22 PM


Views: 44311
uploading an image

Hi,

Im trying to upload an image using php.Im getting the file from a form and on submitting the form it calls a php file.Th file is



<?php

// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir =
'/uploads/';
$uploadfile = $uploaddir . basename
($HTTP_POST_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($HTTP_POST_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
($HTTP_POST_FILES);

print
"</pre>";

?>




When i try to upload it raises a warinin message that the php file does not exists.

Help me to sort out the problem


rork
User

May 3, 2006, 8:03 AM


Views: 44308
Re: [tolearn] uploading an image

Should be an error in your form (or filename). Make sure the file exists, it might have something to do with case-sensitivity or aliasses.
--
Don't reinvent the wheel, use it, abuse it or hack it.