Hi:
I'm having trouble figuring out how to upload a file. I think it has something to do with the upload path since I've tried other things. Question: How do I make sure I am entering the correct path for $uploaddir?
Thanks!
upload code:
<form enctype="multipart/form-data" action="p1.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
processing code:
<?php
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of
// $FILES. In PHP earlier then 4.0.3, use copy() and is_uploaded_file()
// instead of move_uploaded_file
$uploaddir = '/home/whyknotbeads/www/';
$uploadfile = $uploaddir. $FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";
?>
here is the error/info:
Possible file upload attack! Here's some debugging info:
Array
(
[userfile] => Array
(
[name] => spiderman.gif
[type] =>
[tmp_name] =>
[error] => 2
[size] => 0
)
)