我正在使用干涉/图像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);
}
请提供一些用于图片上传的代码。 – user1012181
你有多确定'php_fileinfo'已启用? –
尝试使用phpinfo()来仔细检查php_fileinfo实际上是启用或重新启动Apache后编辑php.ini文件 –