gpt4 book ai didi

javascript - 带有一次性提交按钮的 Dropzone.js

转载 作者:行者123 更新时间:2023-11-30 17:40:59 25 4
gpt4 key购买 nike

实现 Dropzone.js 并希望在所有照片添加到 dropzone 后一次性提交。现在正在 wamp 服务器内使用 PHP kohana 运行。由于某种原因,我无法将照片传递到 php 页面。

js 上的 Dropzone 配置

$(文档).ready(函数() {

   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 科哈纳

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

}

问题是 $_Files 总是空的。任何人都可以提供一些配置方面的帮助吗?

最佳答案

按 F12 并查看网络选项卡(预览)并单击 upload.php 文件你可以看到这样的

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

关于javascript - 带有一次性提交按钮的 Dropzone.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21098652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com