Hi, I'm trying to upload a file to my server. I've done this lots of times before but it's been a while (over a year).
For my current project I'm using the code in the manual: (modified w/ my specs)
Here's the form code:
<form enctype="multipart/form-data" action="URL" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
Here's the image upload code:
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/var/www/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>";
?>
At first when I ran this it gave me the failed error message, then I did a chmod 777 on the directory I'm uploading to and now I get success messages EVERY time, however the file IS NOT uploaded. I check the directory over and over again, I've tried uploading to other directories, etc. When I turn chmod 777 off it doesn't work, so it really seems like this should work it just... doesn't.... any ideas?
Thanks in advance!