I'm on laravel 5.4...
I need to upload some images and make a thumbnail for every single image and save thumbnail in another name.
Well, upload works fine but when I try to resize images and make thumbnail using intervention
package, saved thumbnail seems to be broken.
Please take a look to this picture:
This is my code:
$image = $request->file('ax');
$imagename = mt_rand(999, 999999) . "_" . time() . "_" . $image->getClientOriginalExtension();
$img = Image::make($image->getRealPath());
$width = $img->width();
$height = $img->height();
$img->resize(200, null, function ($constraint) {
$constraint->aspectRatio();
})->save(public_path('storage/' . $token) . '/' . $imagename);
and if I change my storage path
to :
Storage::url($token)
I will get an error says:
Can't write image data to path (/storage/ajxpmXZF2rPfyOu39CcdEgC7Gpi5AlGviysrug88/872130_1496335864_jpg)
Would you please help me to find my problem...?
Thanks in Advance
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire