|
I have this form in html:
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
My problem is that I can't access to the variable userfile and I think the problem was because I use enctype="multipart/form-data"
In the file I access the variable userfile the code is below:
<?php
$uploaddir = '/var/www/uploads/';
$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>";
?>
If I do echo($userfile); in the code above nothing is return!
So I supose that nothing is pass in the userfile variable!
To resolve this problem I use $userfile= $HTTP_POST_VARS["userfile"]; and the enctype as default!
I need to know why doesn't whork with enctype="multipart/form-data"? What I'm doing wrong? It's needed some configuration on php.ini?
|