html 输入类型文件未上传 .mp3

html input of type file not uploading .mp3

我有一个 html 文件类型的输入。用户上传的文件通过 ajax 发送到 php 代码。 我的 html 代码:

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

我的ajax函数:

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

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

               //do somthing
         }
});

我的php代码:

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

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

问题是在 php 方面,当用户上传图片时,代码工作正常,但是当我上传 .mp3 文件时,$file_location 变量是空的,即使$file_name 是正确的。有人知道为什么会这样吗?

请在 php.ini 文件中将 upload_max_filesize=2MB 更改为 upload_max_filesize=32MB 或更多。

如果您想找到 php.ini 文件,请从这里找到帮助 Find the location of php.ini file