2015-04-21 51 views
0

我正在使用干涉/图像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); 
     } 
+0

请提供一些用于图片上传的代码。 – user1012181

+0

你有多确定'php_fileinfo'已启用? –

+0

尝试使用phpinfo()来仔细检查php_fileinfo实际上是启用或重新启动Apache后编辑php.ini文件 –

回答

1

使PHP扩展php_fileinfo,要做到这一点找到你的php.ini文件,取消以下行

; windows 
extension=php_fileinfo.dll 

OR

; linux 
extension=php_fileinfo.so 
+0

我使用主机共享和做没有root权限,但php fileinfo已启用 –

+0

你好,我已经做了取消注释我的XAMPP本地线。共享主机怎么样?因为我在cpanel共享主机中执行困惑? – akbarbin

+0

哪个托管提供商被使用? –

相关问题