Laravel形式下降区

时间:2017-03-10 12:26:43

标签: jquery html forms laravel dropzone.js

好的,我想在一个表单中使用两个不同名称的dropzones,$request->all()只给我一个标记。

我做了什么:

<form action="{{route('FreelancerTestsubmit')}}" class="dropzone" method="post" enctype="multipart/form-data">
    {{ csrf_field() }}
            <div class="col-md-6" style="border: 1px solid black;">
                <h1 id="try-it-out">Try it out!</h1>
                <div id="dropzone">
                    <div class="dropzone needsclick dz-clickable" id="photo1">
                        <div class="dz-message needsclick">
                            Drop files here or click to upload.
                            <br>        
                            <span class="note needsclick">
                                (This is just a demo dropzone. Selected files are <strong>not</strong>
                                actually uploaded.)
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-6" style="border: 1px solid black;">
                <h1 id="try-it-out">Try it out!</h1>
                <div id="dropzone">
                    <div class="dropzone needsclick dz-clickable" id="photo2">
                        <div class="dz-message needsclick">
                            Drop files here or click to upload.
                            <br>        
                            <span class="note needsclick">
                                (This is just a demo dropzone. Selected files are <strong>not</strong>
                                actually uploaded.)
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </form> 

Jquery:

   Dropzone.options.photo1 = {
      paramName: "file",
      maxFilesize: 2, // MB
      accept: function(file, done) {
        if (file.name == "justinbieber.jpg") {
          done("Naha, you don't.");
        }
        else { done(); }
      }

};

现在,操作通过post方法导致控制器方法,$request->all()只给我一个token

如何通过$request->all()获取照片名称及其值?

1 个答案:

答案 0 :(得分:0)

您的dropzone不使用输入。所以它不会出现在请求中。 您可以为每个文件发出ajax请求。

或查看dropzone的维基:https://github.com/enyo/dropzone/wiki/Combine-normal-form-with-Dropzone