这是我的请求代码..
public function rules()
{
return [
'file' => 'nullable|array|min:1',
'file.*' => 'nullable|file|mimes:xlsx|max:50000',
];
}
这是html代码
<form class='curd-form' id='form' @submit.prevent='curd_create("{{$model[0]}}")' method='post' action='{{$path}}{{$model[0]}}' enctype="multipart/form-data">
<input id='file' class='btn btn-success' type='file' {{$file_requires ?? null}} accept='{{$file_types ?? null}}' multiple name='file[]' />
<input type='submit' />
</form>
现在,如果我删除验证一切正常.. 但如果我尝试上传 excel 文件,我得到了这个错误......
这是excel文件
New Microsoft Excel Worksheet.xlsx
现在这发生在我添加到规则验证中的任何类型的文件中,如果我添加的话
'file.*' => 'nullable|file|mimes:xlsx,jpg,png,pdf|max:50000',
我在同一个扩展名中遇到了同样的错误..这是提交表单的 axios 代码
this.show_curd_errors = false;
this.errors = [];
var frm = $('.curd-form');
let formData = new FormData(frm[0]);
var add_or_print = $("#add_or_print").val();
axios.post(path+page_title,formData)
.then((response) =>
{
console.log(response)
}).catch (error => {
console.log(error);
var error = error.response['data']['errors'];
this.errors = error;
hide_loading();
});
我的代码有什么错误..谢谢..
