1/1)LogicException无法猜测mime类型,因为没有猜测器可用(你启用了php_fileinfo扩展吗?)

时间:2017-09-30 08:48:56

标签: php mamp

当我收到错误时,我在服务器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扩展吗?)

有人在这里告诉我类似的问题在网站上,但我尝试所有解决espactally启用"延长= php_fileinfo.dll"通过删除symicolon; 它没有工作所以请帮助我找到解决这个问题并提前感谢

1 个答案:

答案 0 :(得分:0)

如果您正在使用MAMP,请转到

C:\ MAMP \ conf \ php并打开php.ini 然后手动添加“ extension = php_fileinfo.dll”,一切都会正常工作