向Dropzone.js帖子添加更多数据 [英] Adding more data to Dropzone.js post

查看:110
本文介绍了向Dropzone.js帖子添加更多数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在这里实现了本教程: http://www.dropzonejs.com/bootstrap。 HTML

So I have my implementation of this tutorial here: http://www.dropzonejs.com/bootstrap.html

它工作得很好,我上传的文件很好。我想要做的是当Dropzone上传图像时能够在POST数据中发送用户ID和图像。我确实找到了enyo的教程这里,它解释了如何将隐藏的表单数据添加到dropzone,但是使用dropzone提供的bootstrap教程,没有表单,因此不能发送隐藏的帖子数据。

It is working great, and I'm uploading files just fine. What I want to do now is be able to send a user id along with the image in the POST data when Dropzone uploads the image. I did find enyo's tutorial here which explains how to add hidden form data to the dropzone, but using the bootstrap tutorial dropzone provides, there is no form and therefore no hidden post data can be sent.

如何使用上面链接的bootstrap教程中的代码,但仍然将隐藏的输入数据发送到上传脚本?我是否必须以某种方式将提供的代码转换为表单,如果是这样,我该怎么做?

How can I use the code from the bootstrap tutorial linked to above, and yet still send hidden input data to the upload script? Do I have to somehow convert the code provided into a form, and if so, how would I do that?

推荐答案

它已经被一段时间以来,你问这个问题,但基于dropzone网站的提示

It's been a while since you asked this question but based on the dropzone website tips

http://www.dropzonejs.com/#tips

你应该可以做三件事之一 -

you should be able to do one of 3 things -

1。如果有表格添加隐藏的参数。

2。你可以使用这样的参数 -

new Dropzone({
    url: "/",
    params: {
         foo: "bar"
    }
});

3。像这样处理发送事件 -

myDropzone.on("sending", function(file, xhr, formData) { 

// Will sendthe filesize along with the file as POST data.

 formData.append("filesize", file.size);  

});

这篇关于向Dropzone.js帖子添加更多数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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