In this post, I am going to explain all about Image upload in LARAVEL. After https://dev.to/shanisingh03/how-to-install-laravel-9-25c4 open code project in code editor & follow the steps below. Create a Controller to handle all image upload operations by running command below.
validate([ 'image' => 'required|image|mimes:png,jpg,jpeg|max:2048' ]); $imageName = time().'.'.$request->image->extension(); // Public Folder $request->image->move(public_path('images'), $imageName); // //Store in Storage Folder // $request->image->storeAs('images', $imageName); // // Store in S3 // $request->image->storeAs('images', $imageName, 's3'); //Store IMage in DB return back()->with('success', 'Image uploaded Successfully!') ->with('image', $imageName); }}
https://res.cloudinary.com/practicaldev/image/fetch/s--7WzUtMY6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1ao0qw2e7ytf5nx7pg9.png and once you select and image and upload it you will see the success message with image.