4 months ago

Laravel 6 custom validation is not called for file control only and for other controls working fine

Posted 4 months ago by kaushal

Following is the custom validation "file_required"

class AppServiceProvider extends ServiceProvider
    public function boot(Request $request)
        $arr_files = $_FILES;
        $arr_post_data = $request->all();

        echo "here1";

        Validator::extend('file_required', function($attribute, $value, $parameters) use ($arr_files,$arr_post_data) {

            echo "here2";  die;

Following is my html element :
<input type="file" name="photo" id="photo">
Following is  my validatin rule:

"photos" =>"file_required",
"photos.file_required" =>  "Please Select Photos",
Now when i try to submit the form then validation rule is not called means control not comes to on heres2 but comes on here1 in boot method. But when i change input type ="text" then that rule is fired. But i need to fire that custom validation on input type ="file" control.

Can anyone give answer about this what i need to do to work with file control

Please sign in or create an account to participate in this conversation.