unknown_111 unknown_111 -5 years ago 210
Ajax Question

html of type input not uploading .mp3

I have an html input of type file. the files that the user uploads are sent to a php code via an ajax.
My html code:

<input type="file" id="attachments" name="attachments[]" multiple>

My ajax function:

var formData = new FormData(document.querySelector("form"));

$.ajax({url: "target.php",
type:"POST" ,
processData: false,
contentType: false ,
success: function(result){

//do somthing

My php code:

foreach(array_keys($attachments['name']) as $key) {

$file_name = $attachments['name'][$key];
$file_location = $attachments['tmp_name'][$key];
echo $file_name.$file_location;

The problem is that on the php side, when the user uploads an image, the code works just fine, but when i upload a .mp3 file the
variable is empty even though the
is correct. Anyone knows why this happens ?

Answer Source

Please change the upload_max_filesize=2MB to upload_max_filesize=32MB or more in php.ini file.

If you want find the php.ini file then find the help from here Find the location of php.ini file

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download