Laravel Intervention / Image无法在我的主机上运行

时间:2015-04-21 04:02:14

标签: laravel

我使用干预/图片进行laravel并在我的主机中上传laravel项目但图片无法上传。

但是,我的主机中的PHP Fileinfo启用并使用php版本5.4。

错误文字:

"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}

控制器:

$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);
        } 

1 个答案:

答案 0 :(得分:1)

启用PHP扩展程序php_fileinfo,为此找到您的php.ini文件并取消注释以下行

; windows
extension=php_fileinfo.dll

OR

; linux
extension=php_fileinfo.so