【发布时间】:2014-09-11 10:02:18
【问题描述】:
不知道为什么....验证器要么拒绝我所有的文件,因为它们不是图像,要么让它们全部通过... 这是表格:
<!-- The file upload form -->
<form action="{{ URL::route('photographer-gallery-upload-post’) }}" method="POST" enctype="multipart/form-data">
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="col-lg-7">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" name="file[]" multiple>
</span>
@if ($errors->has('file'))
<div class="alert alert-warning" role="alert">
{{ $errors->first('file') }}
</div>
@endif
我的验证:
public function postPhotographerGalleryUpload() {
// Validation of the files to upload
$input = Input::all();
$rules = array( 'file' => 'image|max:15000');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return Redirect::route('photographer-gallery-upload')
->withErrors($validator)
->withInput();
} else {
echo '<pre>';
print_r(Input::all());
echo'</pre>';
die ();}
知道为什么吗??
【问题讨论】:
标签: php image file-upload laravel-4 validation