Atef95's avatar

Laravel No Message exception on file upload

Hey guys

I'm trying to validate some custom rules on my app...

I've a problem with images

I've set custom rules for them....

whenever I try to upload an MP4 or MP3 file I get a No Message Exception error without specifying anything

I can't even get into the method...

it works normally with other type of files...


       $request->validate([
     
            'photo' => 'image|mimes:jpeg,png,jpg|max:2048',

        ], [
       
            'photo.image' => 'Le format du photo importé est non supporté ',
            'photo.mimes' => 'Le format du photo importé est non supporté ',
            'photo.max' => 'Photo importé est volumineux ! ',
        ]);

0 likes
3 replies
Braunson's avatar

Does your form have the enctype set to multipart/form-data?

Atef95's avatar

I have it ..

   <form role="form" method="post" enctype="multipart/form-data"
                        action="{{route('handleAddWarehouse')}}">
                        {{csrf_field()}}

  <input type="file" class="form-control" name="photo">

</form>

the problem is with large files like MP4 or MP3... it redirects to No Message Exception

pipariyah1's avatar

Please check your php.ini for maximum size of upload a file. I think the issue is there. You need to increase the upload_max_filesize. You can also check by placing these two lines ini_set('upload_max_filesize', '1024M'); ini_set('post_max_size', '1024M'); in you index.php at very begining just after:<?php

Please or to participate in this conversation.