如何使用流明上传多个文件 [英] How to upload multiple files using Lumen Multiple file upload
本文介绍了如何使用流明上传多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我到目前为止尝试过的代码.有人可以建议如何更改此代码以上传多个文件吗?
This is the code I tried so far. Could any one suggest how to alter this code to upload multiple files ?
public function uploadFile(Request $request){
$file = $request->file('image') ;
$fileName = time().$request->file('image')->getClientOriginalName();
$destinationPath = $request->input('path') ;
return $file->move($destinationPath,$fileName);
}
推荐答案
$file_ary = array();
$file_count = count($request->file('image') );
$a=($request->file('image'));
$finalArray=array();
$file_count;
for ($i=0; $i<$file_count; $i++) {
$fileName = time().$a[$i]->getClientOriginalName();
$destinationPath = $request->input('path') ;
$finalArray[$i]['image']=$destinationPath.$fileName;
$a[$i]->move($destinationPath,$fileName);
}
return json_encode($finalArray); // it will return the upload path
这篇关于如何使用流明上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文