vendredi 27 septembre 2019

how i can solve unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?) in laravel 5.5

controller

 public function store(Request $request)
{
    $this->validate($request, [
        'title' => 'required',
        'body' => 'required',
        'cover_image' => 'image|nullable|max:1999'
    ]);

    // Handle File Upload
    if($request->hasFile('cover_image')){
        // Get filename with the extension
        $filenameWithExt = $request->file('cover_image')->getClientOriginalName();
        // Get just filename
        $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
        // Get just ext
        $extension = $request->file('cover_image')->getClientOriginalExtension();
        // Filename to store
        $fileNameToStore= $filename.'_'.time().'.'.$extension;
        // Upload Image
        $path = $request->file('cover_image')->storeAs('public/cover_images', $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');

i enabled this extension

extension=php_fileinfo.dll

my laravel version 5.5

when i upload image i getting this error

Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)

i think error on image validation

any one have idea about that??



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire