Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LaraWebDev1's avatar

Image Upload => LogicException Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)

I'm following the following tutorial -> http://laraveldaily.com/upload-multiple-files-laravel-5-4. When I go to post my advert, the add goes thorugh without the photographs. My error message is

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

I have enabled php_fileinfo and restared the server, but to know avail. Any other ideas on how to fix this?

    public function store(Request $request){

      

    $Advert = PropertyAdvert::create([
        "address"     => $request->address,
        "county"      => $request->county,
        "town"        => $request->town,
        "type"        => $request->type,
        "rent"        => $request->rent,
        "date"        => $request->date,
        "bedrooms"    => $request->bedrooms,
        "bathrooms"   => $request->bathrooms,
        "furnished"   => $request->furnished,
        "description" => $request->description,
        "user_id" => Auth::id(),
    ]);

    
    foreach ($request->photo as $photo) {
            $filename = $photo->store('photo');
            PropertyAdvertPhoto::create([
                'property_id' => $Advert->id,
                'filename' => $filename
            ]);
          }

    $id = $Advert->id;

    return redirect("/property/$id");
  }

UploadRequest "Request File"

This is where all the validation rules are stored. <?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UploadRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
          return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
      $rules = [
              'address' => 'required'
          ];
          $photos = count($this->input('photo'));
          foreach(range(0, $photos) as $index) {
              $rules['photo.' . $index] = 'min:100';
          }

          return $rules;

    }


}

Upload Form

 <form method="POST" action="/property" enctype="multipart/form-data">
                        {{ csrf_field() }}
                       
                          <div class="form-group row">
                              <label for="photo" class="col-md-3 col-form-label text-md-right">Images</label>
                              <div class="col-md-9">
                                <input required type="file" class="form-control" name="photo[]" multiple>
                              </div>
                            </div>
0 likes
10 replies
Grelav's avatar

Please make sure you have enabled the file extension

;extension=php_fileinfo.dll to extension=php_fileinfo.dll

try uploading different images from the once you already tried

dump the $photo for debugging and lets see what you have

foreach ($request->photo as $photo) {
    ....
    dd($photo);
    ....
}
LaraWebDev1's avatar

I have already enabled the file extension, or did you mean another me?

dd($photo) gives me

UploadedFile {#203 ▼ -test: false -originalName: "20171030_164431.jpg" -mimeType: "application/octet-stream" -size: 0 -error: 1 #hashName: null path: "" filename: "" basename: "" pathname: "" extension: "" realPath: "C:\Users\andre\Dropbox\College\Project\Rentable\public" aTime: 1970-01-01 00:00:00 mTime: 1970-01-01 00:00:00 cTime: 1970-01-01 00:00:00 inode: false size: false perms: 00 owner: false group: false type: false writable: false readable: false executable: false file: false dir: false link: false }

Grelav's avatar

you have to make sure your "C:\Users\andre\Dropbox\College\Project\Rentable\public" directory permissions are set correctly.

Grelav's avatar

no, it is within your OS environment

the belove are how would an acceptable properties be when a file is good for storing using Laravel Store method.

watch the Readable and Writable Proberties.

UploadedFile {#357 ▼
  -test: false
  -originalName: "167906_60_news_hub_multi_630x0.png"
  -mimeType: "image/png"
  -size: 463243
  -error: 0
  #hashName: null
  path: "C:\Windows\Temp"
  filename: "php23DF.tmp"
  basename: "php23DF.tmp"
  pathname: "C:\Windows\Temp\php23DF.tmp"
  extension: "tmp"
  realPath: false
  aTime: 2018-03-18 16:02:56
  mTime: 2018-03-18 16:02:56
  cTime: 2018-03-18 16:02:56
  inode: 0
  size: 463243
  perms: 0100666
  owner: 0
  group: 0
  type: "file"
  writable: true
  readable: true
  executable: false
  file: true
  dir: false
  link: false
  linkTarget: "C:\Windows\Temp\php23DF.tmp"
}
Grelav's avatar

Try

$destinationPath = 'storage' .  DIRECTORY_SEPARATOR

foreach ($request->photo as $photo) {
            $filetype = $photo->getClientOriginalExtension();
            $filename = uniqid(time()). '.' . $filetype;
        $photo->move($destinationPath,$filename);
            PropertyAdvertPhoto::create([
                'property_id' => $Advert->id,
                'filename' => $filename
            ]);
          }
LaraWebDev1's avatar

I have the above working now. My only issue is that they're stored as .tmp files and I have no idea how to display them? Any suggestions there?

Grelav's avatar

have you solve the problem of .tmp ?

Please or to participate in this conversation.