如何使用流明上传多个文件多个文件上传

时间:2017-12-28 07:08:05

标签: php lumen

这是我到目前为止尝试的代码。任何人都可以建议如何更改此代码以上传多个文件?

  public function uploadFile(Request $request){
                $file = $request->file('image') ;
                $fileName = time().$request->file('image')->getClientOriginalName();

                $destinationPath = $request->input('path') ;
                return  $file->move($destinationPath,$fileName);
    }

1 个答案:

答案 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