2015-04-21 52 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

哪個託管提供商被使用? –

相關問題