Reputation: 299
i want to validate the file input field, am new in laravel so i cant figure out what am missing.
here is my code:
public function postUploadS(){
$file = array(Input::file('file'));
$rule = array('file' => 'required');
$validate = Validator::make($file,$rule);
if($validate->fails()){
var_dump($file); exit();
}
else{
return View::make('admin.uploadStaff'); }
}
I i cant get to the uploadStaff view even if i choose the file, any help please
Upvotes: 0
Views: 571
Reputation: 1003
It looks like your problem is that the $file
array isn't associative, meaning the validator doesn't see any input to compare the file
rule in $rule
against.
Change: $file = array(Input::file('file'));
to: $file = array('file' => Input::file('file'));
...and the validator now knows what input to run against your rule.
Upvotes: 1