Download bootstrap file input https://github.com/kartik-v/bootstrap-fileinput #include-files include files #css css Exit fullscreen mode #js JS

Exit fullscreen mode #init-file-input init file input Exit fullscreen mode https://res.cloudinary.com/practicaldev/image/fetch/s--RvXSzFD9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9gg6pezsl8dmi5tmifkv.png #server server public function store(){ $images = []; $files = $request->images; foreach($files as $file){ $textRandom=Str::random(20).time(); $extenstion= $file->getClientOriginalExtension(); $fileName=$textRandom.".".$extenstion; $file->move(public_path('uploads/'), $fileName); $images[]=["name"=>$fileName ]; } Exit fullscreen mode #edit-images edit images #server server public function get_images(){ $images = Image::get(); return view('edit',compact('images')); } public function destroyImg($imgId){ $img=Image::whereId($imgId)->first(); // check image in database if(!$img){ return response() ->json(['error'=>'Sorry, the image is not in the database']); } // check image in files if(!File::exists('uploads/'.$img->name)){ return response() ->json(['error'=>'Sorry, the image is not in the file folder']); } unlink('uploads/'.$img->name); $img->delete(); return true; }
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners