MNamazi
MNamazi

Reputation: 101

Laravel Intervention/Image not work on My host

I'm using intervention/image for laravel and upload laravel project in my Host but image not upload.

However, PHP Fileinfo in my host in enable and use php version 5.4 .

error text :

"error":{"type":"LogicException","message":"Unable to guess the mime type as no 
guessers are available (Did you enable the php_fileinfo 
extension?)","file":"\/home\/investi1\/vendor\/symfony\/http-
foundation\/Symfony\/Component\/HttpFoundation\/File\/MimeType\/MimeTypeGuesser.
php","line":127}

Controller :

$image = Input::file('file');
        $destinationPath = 'uploads/gallery';
        $filename =  $image->getClientOriginalName();
        $extension =$image->getClientOriginalExtension();
        $image_filename = sha1($filename).'-'.rand(0,1000).'.'.$extension;
        $image_uploadSuccess = $image->move($destinationPath, $image_filename);

        $img = Image::make($destinationPath.'/'.$image_filename);
        $img->resize(150, null, function ($constraint) {
            $constraint->aspectRatio();
        })->save($destinationPath.'/tumb/'.$image_filename,70);

        $img_gallery = new ImageGallery;
        $img_gallery->user_id = Sentry::getUser()->id;
        $img_gallery->lang = Security::xss_clean(Input::get('lang'));
        $img_gallery->description = Security::xss_clean(Input::get('description'));
        $img_gallery->cat_id = Security::xss_clean(Input::get('category'));
        $img_gallery->image = $image_filename;
        $img_gallery->created_at = jDate::forge()->time();

        if( $image_uploadSuccess ) {
            $img_gallery->save();
            return Response::json('success', 200);
        } else {
            return Response::json('error', 400);
        } 

Upvotes: 1

Views: 2782

Answers (1)

Jay Dhameliya
Jay Dhameliya

Reputation: 1699

enable PHP extension php_fileinfo, to do this find your php.ini file and uncomment following line

; windows
extension=php_fileinfo.dll

OR

; linux
extension=php_fileinfo.so

Upvotes: 4

Related Questions