大家好我的项目需要帮助laravel如何在后端处理这个问题?
如果你有多个输入怎么样:
Photo 1:
<input type="file" name="name">
Photo 2:
<input type="file" name="name">
$file_upload = [];
$("input[name=name]").each(function()){
$upload_val = $(this).prop('files')[0];
$file_upload.push($upload_val);
}
var data_post = new FormData();
data_post.append('uploads',$file_upload);
$.ajax({
url: "app/upload",
type: "POST",
processData: false,
contentType: false,
data: data_post,
success:function(res){
console.log(res)
}
});
答案 0 :(得分:0)
我相信你可以做点什么
您的HTML
<input type="file" value="photos[]">
<input type="file" value="photos[]">
你的后端
$photos = $request::file('photos')
foreach($photos as $photo) {
// your code
}