kaushal's avatar

For multiple file uploading i am using following validatin rule but whather i am uploading an image or not it is giving me 'Please upload an image only' error message.

 public function store(Request $request)
{
    
    $this->validate($request, [
        'images.*' => 'required'
      ],[
        'images.*.required' => 'Please upload an image only'
    ]);
   
    // Write your code
}

{!! Form::open(['enctype' =>'multipart/form-data']) !!}

<input type="file" value="" id="images1" name="images[]">
<input type="file" value="" id="images2" name="images[]">

@if($errors->has("images.*")) {{  $errors->first('images.*') }} @endif
{!! Form::close() !!}
0 likes
6 replies
kaushal's avatar
{!! Form::open(['enctype' =>'multipart/form-data']) !!}

<input type="file" value="" id="images1" name="images[]">
<input type="file" value="" id="images2" name="images[]">

@if($errors->has("images.*")) {{  $errors->first('images.*') }} @endif
{!! Form::close() !!}
CodingIsEasy's avatar
$this->validate($request, [
        'images' => 'required'
      ],[
        'images.required' => 'Please upload an image only'
    ]);

would that work? ^

1 like

Please or to participate in this conversation.