Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel/验证不适用于我的文件输入?_Php_Image_File Upload_Laravel 4_Validation - Fatal编程技术网

Php Laravel/验证不适用于我的文件输入?

Php Laravel/验证不适用于我的文件输入?,php,image,file-upload,laravel-4,validation,Php,Image,File Upload,Laravel 4,Validation,不明白为什么。。。。验证器要么拒绝我的所有文件,因为它们不是图像,要么让它们全部通过。。。 表格如下: <!-- The file upload form --> <form action="{{ URL::route('photographer-gallery-upload-post’) }}" method="POST" enctype="multipart/form-data"> <!-- The fileupload-buttonbar contai

不明白为什么。。。。验证器要么拒绝我的所有文件,因为它们不是图像,要么让它们全部通过。。。 表格如下:

<!-- 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 

添加文件。。。
@如果($errors->has('file'))
{{$errors->first('file')}
@恩迪夫
以及我的核实:

    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 ();}
public函数postPhotographerGalleryUpload(){
//验证要上载的文件
$input=input::all();
$rules=数组('file'=>'image | max:15000');
$validator=validator::make($input,$rules);
如果($validator->fails()){
返回重定向::路由('photopher-gallery-upload')
->威瑟罗($validator)
->withInput();
}否则{
回声';
打印(输入::all());
回声';
死亡();}
知道为什么吗???

使用Laravel打开和关闭窗体,如下所示:

/'files'=>必须为true
{{Form::open(数组('url'=>'foo/bar','files'=>true))}
{{Form::close()}}

在您的控制器中,使用
Input::hasFile()
Input::file()
方法。

为什么它不能与basic一起工作?我在许多其他页面中使用过它,验证文本输入时没有问题。。。