带有一次提交按钮的Dropzone.js [英] Dropzone.js with onetime submit button

查看:387
本文介绍了带有一次提交按钮的Dropzone.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在实施Dropzone.js,并希望在将所有照片添加到Dropzone之后一次性提交.目前,这是在wamp服务器中与PHP kohana一起运行的.由于某些原因,我无法将照片传递到php页面.

Implementing Dropzone.js and would like to have a onetime submit after all photos are added to the dropzone. This is running with PHP kohana inside a wamp server right now. For some reason I am unable to pass the photos to the php page.

js上的Dropzone配置

Dropzone config on js

$(document).ready(function(){

$(document).ready(function() {

   Dropzone.options.dropzoneForm = {
            // The camelized version of the ID of the form element

            paramName: "files",
            autoProcessQueue: false,
            uploadMultiple: true,
            parallelUploads: 100,
            maxFiles: 100,
            previewsContainer: ".dropzone-previews",
            clickable: true,
            dictDefaultMessage: 'Add files to upload by clicking or droppng them here.',
            addRemoveLinks: true,
            acceptedFiles: '.jpg,.pdf,.png,.bmp',
            dictInvalidFileType: 'This file type is not supported.',

            // The setting up of the dropzone
            init: function () {
                var myDropzone = this;

                $("button[type=submit]").bind("click", function (e) {
                    e.preventDefault();
                    e.stopPropagation();
                    // If the user has selected at least one file, AJAX them over.
                    if (myDropzone.files.length !== 0) {
                        myDropzone.processQueue();
                    // Else just submit the form and move on.
                    } else {
                        $('#dropzone-form').submit();
                    }
                });

                this.on("successmultiple", function (files, response) {
                    // After successfully sending the files, submit the form and move on.
                    $('#dropzone-form').submit();
                });
            }
        }
   });

表格

 <div id="photoContainer">

        <form action="/inspections/uploadphotos" method="post" 
        enctype="multipart/form-data" class="dropzone dz-clickable dropzone-previews" id="dropzone-form">

        </form>
           <button type="submit" id="dz" name="dz" value="Submit " /> Submit Photos</button>
    </div>

PHP Kohana

PHP Kohana

    if (!empty($_FILES)) {
    print_r($_FILES);

}

问题在于$ _Files始终为空.任何人都可以在配置方面提供一些帮助吗?

The problem is that $_Files is always empty. Can anyone provide some assistance on configuring this?

推荐答案

按F12键并查看网络"标签(预览),然后单击"upload.php"文件,您会看到类似的内容

Press F12 and see the network tab (preview) and click upload.php file u can see like this

Array( [file] => Array ( [name] => migration_3.jpg [type] => image/jpeg [tmp_name] => D:\xampp\tmp\phpA76F.tmp [error] => 0 [size] => 214924 ))

这篇关于带有一次提交按钮的Dropzone.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆