简体   繁体   English

dropzone with jquery及其选项

[英]dropzone with jquery and its options

I am using dropzone for file attachment and upload, I dont want to bind dropzone with form elements as i can not put form inside form, 我使用dropzone进行文件附加和上传,我不想将dropzone与表单元素绑定,因为我无法将表单放在表单中,

So i binded it to div element using jquery, 所以我使用jquery将它绑定到div元素,

I can upload document correctly with this, but i can not find any way to give options when using as jquery, 我可以用这个正确上传文档,但是在使用jquery时我找不到任何方法来提供选项,

below are my codes, 以下是我的代码,

I had binded dropzone as class and ID, If i remove class, then dropzone is not attaching to div and i can not attach file. 我把dropzone作为类和ID绑定了,如果我删除了类,那么dropzone没有附加到div而我无法附加文件。

 <div class="dropzone" id="dropzoneattach">

 </div>

Here is Jquery, 这是Jquery,

$("#dropzoneattach").dropzone({ 
paramName : 'userfile',
url: "<?php echo base_url()?>index.php/news/add_attachments",
});

why i am binding with this, because i want file name which uploads as userfile, not file. 为什么我绑定这个,因为我想要上传为用户文件的文件名,而不是文件。

While doing this way, i can not upload file, 这样做时,我无法上传文件,

If there anything wrong? 如果有什么不对? How to give dropzone options when dropzone is creating programatically, i tried to look in documentation but could not understood, 当dropzone以编程方式创建时,如何提供dropzone选项,我试图查看文档,但无法理解,

Thanks advanced. 谢谢先进。

Finally, i found myself, Below is just binded with class, 最后,我发现自己,下面只是与班级结合,

$(".dropzone").dropzone({ 
paramName : 'userfile',
url: "<?php echo base_url()?>index.php/news/add_attachments"
)}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM