You can use intervention for the image information
http://image.intervention.io/getting_started/installation#laravel
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
In laravel, how can I store the images with file type, file size, dimension and also with file URL. can someone help me, how can I get these field. THis is my store function for image
public function store(Request $request)
{
request()->validate([
'image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$image = $request->file('image');
$extension = $image->getClientOriginalExtension();
$originalname = $image->getClientOriginalName();
$path = $image->move('uploads\media', $originalname);
$mimetype = $image->getClientMimeType();
$picture = new mediaLibrary();
$picture->mime = $mimetype;
$picture->original_filename = $originalname;
$picture->filename = $path;
$picture->save();
return redirect()->route('media.index');
}
public function show($id)
{
$data = mediaLibrary::findOrFail($id);
return view('mediaLibrary.show',compact('data'));
}
public function store(Request $request)
{
request()->validate([
'image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$image = $request->file('image');
$extension = $image->getClientOriginalExtension();//Getting extension
$originalname = $image->getClientOriginalName();//Getting original name
$path = $image->move('uploads/media/', $originalname);//This will store in customize folder
$imgsizes = $path->getSize();
$data = getimagesize($path);
$width = $data[0];
$height = $data[1];
$mimetype = $image->getClientMimeType();//Get MIME type
//Start Store in Database
$picture = new mediaLibrary();
$picture->mime = $mimetype;
$picture->imgsize = $imgsizes;
$picture->original_filename = $originalname;
$picture->extension = $extension;
$picture->width = $width;
$picture->height = $height;
$picture->filename = $path;
$picture->save();
//End Store
return redirect()->route('media.index');
}
Please or to participate in this conversation.