lundi 9 décembre 2019

Image source not readable : Image Upload in Laravel

I'm trying to upload an image to our system. It is working well when I'm using it in localhost but when I'm testing in server, it's throwing an error Image source not readable. I'm trying to upload a 2.2MB photo since my max size of image upload is 3MB. Uploading images less than or equal to 2MB in server has no problem but in local, it accepts up to 3MB in which it is the expected behavior. I'm using docker for my local development and my server is CentOS7. Is there some configurations I should touch so that it can accept 3MB image size in my server? Or is there something I have to change in my code below in processing the image?

REQUEST

public function rules()
{
    return [
        'photo' => 'image|mimes:jpeg,png,jpg|max:2048',
    ];
}

Controller

$photo = $request->file('photo');

$server_dir = storage_path(config('const.upload_local_temp_path'));
FileHelper::addDirectory($server_dir, 0777);

$file_name = FileHelper::makeUniqFileName($photo->getClientOriginalExtension(), $server_dir);
$filepath = $server_dir . $file_name;
$img_path = FileHelper::storeResizeImg($photo->path(), $filepath, null, 300);
$img_url = FileHelper::getPublicPath($img_path);
return $img_url;

Please let me know of your thoughts.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire