这是我到目前为止尝试的代码。任何人都可以建议如何更改此代码以上传多个文件?
public function uploadFile(Request $request){
$file = $request->file('image') ;
$fileName = time().$request->file('image')->getClientOriginalName();
$destinationPath = $request->input('path') ;
return $file->move($destinationPath,$fileName);
}
答案 0 :(得分:0)
$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