I've create an app that upload image along with title, description & etc. However, i'm having a problem in some of the images to upload, it returns an error ("Image source not readable") as shown below:
Here's my Code:
$image = $request->file('image');
// $image = Input::file('image'); // already tried this one still same problem
$orginal_filename = $image->getClientOriginalName();
$ext = $image->getClientOriginalExtension();
$fileName = md5(microtime() . $orginal_filename) . '.' . $ext;
$img = Image::make($image->getRealPath());
$img->stream();
$img->resize(1200, null, function ($constraint) {
$constraint->aspectRatio();
});
Storage::disk('storage_dir')->put($dir . $fileName, $img, 'public');
Already tried following solutions:
but still have the "Image source not readable" error.
Note: Error only occurs in some images. (I've also tried moving the image(w/c produced the errors) into another directory but still error occurs).
Thank you so much for the help!
If the problem occours in a Laravel 5.7 project, and you store your pictures in the storage folder, it might solve the problem to enter this into the terminal:
php artisan storage:link
(The problem occurs if you have cloned the project from github og bitbucket)