jeudi 25 octobre 2018

The photo must be a file of type: jpeg, bmp, png. Mimes Laravel 5.7

When I tried to validate a file (I need JPG,BMP and PNG to be uploaded) the following message persist when I upload the proper files.

The photo must be a file of type: jpeg, bmp, png.

My form looks like,

<form class="form-horizontal form-material" action="submitapplication" method="post"  enctype="mutipart/form-data">

 <div class="row form-inline" style="margin-left:30px;">
     <div class="col-md-5">
         <label>Photo</label>
         <div class="image-upload">
             <label for="file-input">
               <img src=""  width="128px"
                height="128px" data-toggle="tooltip" data-placement="right" 
                title="Upload Profile Picture">
             </label>
             <input id="file-input" name="photo" type="file" 
              style="display:none;" />
          </div>
       </div>
       <div class="col-md-5">
          <label>Upload Proof Copy</label>
          <div class="image-upload">
          <label for="proof-input">
             <div style="width:128px;height:128px;">
                 <img src="" width="75px"
                  height="75px" data-toggle="tooltip" data-placement="right" 
                  title="Upload Proof" style="margin-top: 25px;">
             </div>
          </label>
          <input id="proof-input" name="proof" type="file" style="display:none;" 
           />
      </div>
   </div>
   <div class="row" style="margin-left:350px;">
      <div class="col-sm-5">
         <button class="btn btn-success" style="width:100px;">Save</button>
      </div>
      <div class="col-md-5">
           <button class="btn btn-danger" style="width: 100px;">Cancel</button>
      </div>
   </div>
</form>

The validation part in the controller,

$data=Validator::make($req->all(), ['photo'=>'required|mimes:jpeg,bmp,png',
'proof'=>'required|mimes:pdf,doc,docx'])->validate();

I've used Validator class,

use Validator;

I can't go forward without this anyone please help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire