当我在服务器MAMP上的laravel 5.4上的站点上工作时,我得到了这个错误,当时我得到了在Store函数中显示的错误,其中包含:
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required',
'body' => 'required',
'cover_image' => 'image|nullable|max:1999'
]);
//Handle the File
if($request->hasFile('cover_image')){
//Get file name with extension
$fileNameWithExt = $request->file('cover_image')->getClientOriginalName();
//Get just file name
$filename = pathinfo($fileNameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $request->file('cover_image')->getOriginalClientExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload the file
$path = $request->file('cover_image')->storeAs('public/cover_image', $fileNameToStore);
} else{
$fileNameToStore = 'noimage.jpg';
}
//Create Post
$post = new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post->user_id = auth()->user()->id;
$post->cover_image = $fileNameToStore;
$post->save();
return redirect('/posts')->with('success', 'Post Created');
}错误:
1/1) LogicException
无法猜测mime类型,因为没有可用的猜测程序(您是否启用了php_fileinfo扩展?)
有人告诉我这里类似的问题,在网站上,但我尝试所有的解决办法,特别是启用“extension=php_fileinfo.dll”删除符号;它不工作,所以请帮助我找到解决这个问题,并提前感谢你
发布于 2018-09-20 03:38:45
如果您使用的是MAMP,请转到
C:\MAMP\conf\php并打开php.ini,然后手动添加"extension=php_fileinfo.dll“,一切都应该正常工作
https://stackoverflow.com/questions/46501169
复制相似问题