dimanche 18 mars 2018

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.

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">
                        

                          <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>



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2GI5uKU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire