简体   繁体   English

axios文件发布,在服务器端接收空数组

[英]axios file post, receiving empty array at server side

I am trying to upload a excel file using axios and php. 我正在尝试使用axios和php上传Excel文件。 when I post a file with axios I getting empty post array at php side my code 当我用axios发布文件时,我在php端得到空的发布数组我的代码

var formdata = new FormData(); 

 var filedata = document.getElementById('file-upload').files[0];

 formdata.append('paymentfile',filedata);

 const result = uploadFile(formdata);
 result.then(function(response){ }

//my uploadFile function is like


uploadFile(data){
const confi = {
    headers: { 'content-type': 'multipart/form-data' }
}

const url = "http://localhost/codeigniter/user/uploadExcel";
return axios.post(url,data,confi);
}

The file you're uploading is too large based on your php.ini settings: 根据您的php.ini设置,您要上传的文件太大:

upload_max_filesize = 2M
post_max_size = 2M

Increase those settings. 增加这些设置。

PHP will outright ignore the upload if the content-size header is larger then your server configuration, and thus the $_FILES array will be empty. 如果content-size标头大于您的服务器配置,PHP将完全忽略上载,因此$ _FILES数组将为空。 Which is very annoying, because it makes it very hard to report on what file failed when your application allows multiple files to be uploaded at once via AJAX. 这很烦人,因为当您的应用程序允许通过AJAX一次上传多个文件时,很难报告失败的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM