简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM