I am trying to upload a news item that requires a image and a message
my form looks like
<form action="/admin/nieuws/toevoegen" method="post" enctype="multipart/form-data">
<div class="form-group">
<input type="text" class="form-control" id="titel" name="titel" placeholder="Titel">
</div>
<div class="form-group">
<label for="bericht">Het bericht</label>
<textarea name="bericht" id="bericht" placeholder="Het nieuwsbericht">tester</textarea>
</div>
<div class="form-group">
<label for="exampleInputFile">Afbeelding </label>
{{ Form::file('file', array('multiple'=>true, 'id'=> 'file'));}}
<p class="help-block">350px x 200px</p>
</div>
<button type="submit" class="btn btn-success">Toevoegen</button>
{{ Form::close() }}
any my form handling looks like.
public function postAddNieuws()
{
$rules = array(
'titel' => array('required', 'unique:nieuws,titel', 'min:7'),
'bericht' => array('required'),
'file' => array('required','image')
);
$validation = Validator::make(Input::all(), $rules);
if ($validation->fails())
{
return Redirect::to('admin/nieuws/toevoegen')
->withErrors($validation)
->withInput();
}
else
{
return View::make('admin.nieuws.toevoegen');
}
}
it dos not check the file and skips the image check what am i doing wrong?
files is plural in your validation rules, but singular when you declare the field in the view. Change your rule to 'file' instead of 'files'
stickman373 said:
files is plural in your validation rules, but singular when you declare the field in the view. Change your rule to 'file' instead of 'files'
i changed it still the same problem
If i fill in everything except a file i only get the file is required error if i fill in everyting with the file i get a error for every (title required, bericht required, file requiered)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community