Reputation: 63626
<form enctype="multipart/form-data">
<input type="file" name="mp3" />
<input type="submit" />
</form>
I tried the above,and found var_dump($_FILES);
is always empty.
It only works when you upload text files or images.
UPDATE
I added method="POST"
and it works.Why is POST
necessary here?
Upvotes: 1
Views: 6848
Reputation: 449385
MP3 file uploads should work like any other file upload, there's no discrimination by file type or extension.
Check whether your file is not larger than allowed.
PHP manual on file uploads: Common pitfalls
Update: @Adhip Gupta solved it. GET seems to be the default method for a FORM, not POST as I thought. Check here: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.1
This attribute specifies which HTTP method will be used to submit the form data set. Possible (case-insensitive) values are "get" (the default) and "post". See the section on form submission for usage information.
Upvotes: 5
Reputation: 16640
Maybe you have missed the MAX_FILE_SIZE which should be included.
<input type="hidden" name="MAX_FILE_SIZE" value="157286400" />
You should also add action="some.php"
and method="POST"
to <form>
Upvotes: 0
Reputation: 48357
Nothing wrong with your PHP code. And neither PHP nor the webserver know the difference between a MP3 file and other types of content.
Have you checked its not size related?
Do you know that there isn't other things between the browser and the PHP which might be filtering?
Have you tried using a wiretap (e.g. wireshark) to confirm the data is leaving the browser / getting to the server?
C.
Upvotes: 0
Reputation: 29953
First thing to check is how big the files are, and what the max upload size in PHP.ini is set to.
Upvotes: 0
Reputation: 7163
Did you specify the form method to be POST explicitly and try?
Upvotes: 4