Hi there.
I am having a tough time trying to upload files through PHP.
My form:
<form action="blah.php" enctype="multipart/form-data" method="post">
<p> Upload file: <input type="file" name="xmlfile"/>
<input type="submit" name="upload_submit" value="Upload" /> </p>
</form>
Checklist:
No 'smart' quotes in sight. Fine.
Proper enctype. Fine.
name attrib in input tag. Fine.
My
/tmp
directory has the following permissions:drwxrwxrwt
. Fine.post_max_size = 50M, upload_max_filesize = 50M, file_uploads = On. Fine.
print_r($_FILES)
gives Array()
. Useless. Tried on images, xml files, etc. Nothing works.
What I don't understand even further is that there are pages on which file uploading works on the same server. The only thing different from what I can gather is that the page I am working on has a few other forms which aren't of enctype="multipart/form-data"
. Should this matter?
PHP code as requested:
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if(isset($_POST['upload_submit'])){
print_r($_FILES);
exit();
...
}
}
Gives an empty array regardless of print_r
's position; I also tried it right after the if($_SERVER['REQUEST_METHOD'] == 'POST'){