VedantInfoWays/ June 1, 2019/ Laravel/ 0 comments

Upload multiple files in laravel

Upload multiple files

 

Upload multiple files
$VehicleId = $vehicle->id;
            $savepath = ABSVehicle;
            if (!File::exists($savepath.$VehicleId)) {
                File::makeDirectory($savepath.$VehicleId, 0755, true);
                File::makeDirectory($savepath.$VehicleId.'/Thumb', 0755, true);
            }
            $newpath = $savepath.$VehicleId.'/';



if(Input::hasFile('photos')){
                $files = Input::file('photos');
                foreach ($files as $file) {
                    $imgname = 'Document'.time().'_'.rand(000,999);
                    $filename  = $imgname. '.' . $file->getClientOriginalExtension();
                    $Orgfilename = $file->getClientOriginalName();
                    $file->move($newpath, $filename);
                    if(in_array(strtolower($file->getClientOriginalExtension()),['png','jpg','jpeg','bmp','gif'] )){
                      ImageHelper::resize_crop_image(150, 150, $newpath.$filename , $newpath.'Thumb/'.$filename, 80);
                    }
                }
            }

Share this Post

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
*
*