在Laravel Controller中无法访问Dropzone.js上传的文件

时间:2018-09-06 04:15:05

标签: laravel laravel-5 dropzone.js

有一个名为Image的模型,它具有filetitlephotographer等。我需要让用户上传多个图像,然后显示每个图像的其他字段的形式。因此,我选择了Dropzone,并且需要不进行Ajax上传。这是表格

@extends('layouts.layout')
<link rel="stylesheet" href="{{asset('css/dropzone.css')}}" />
@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-12 text-right">
                <div class="widget">
                    <div class="widget-header">
                        <span> Multi Image Upload </span>
                        <i class="icon-picture mr-2"></i>
                    </div>
                    <div class="widget-content">
                        @include('layouts.message')
                        <SECTION>
                            <DIV id="dropzone">
                                {!! Form::open([ 'route' => [ 'images.multiUploadStore' ], 'files' => true, 'enctype' => 'multipart/form-data', 'class' => 'dropzone py-5 px-1 text-center w-100', 'id' => 'image-upload' ]) !!}
                                    <DIV class="dz-message needsclick" id="demo-upload">
Drag and Drop Your Files Here
                                    </DIV>
                                    <div class="mx-auto text-center clearfix col-sm-12">
                                        {{Form::submit('Submit',['class'=>'btn btn-primary','name'=>'submit', 'id'=>'submit'])}}
                                    </div>
                                {!! Form::close() !!}
                            </DIV>
                        </SECTION>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('scripts')
<script src="{{asset('js/dropzone.js')}}"></script>
    <script>
        Dropzone.options.imageUpload = {
            maxFilesize         :       1,
            acceptedFiles: ".jpeg,.jpg,.png,.gif"
        };
    </script>
@endsection

这是控制器

public function multiuploadstore(Request $request)
{
    $images = $request->file('file');
    dd($images);
}

,它返回null。如何访问控制器内部的文件?

谢谢。

1 个答案:

答案 0 :(得分:0)

请检查此教程: Dropzone File Upload