dongliang2005 2015-04-25 04:14
浏览 73

如何使用dropzone js发布其他表单字段?

I have an HTML form with a dropzone js file upload. I want to post other form field information with the file. I tried this code,

HTML

<script src="dropzone/dist/dropzone.js"></script>
<link rel="stylesheet" href="dropzone/dist/dropzone.css">

<form role="form" id="my-awesome-dropzone" method="post" action="photos/post"  enctype='multipart/form-data'>
     <input type="text" name="title" id="title" class="form-control input-lg" placeholder="Title" >
     <input type="text" name="location" id="location" class="form-control input-lg" placeholder="Location">
     <div class="dropzone dz-clickable" id="myDrop">
        <div class="dz-default dz-message" data-dz-message="">
            <span>Drop files here to upload</span>
        </div>
     </div>
    <input type="button" value="Post" id="post-btn">

Javascript

<script type="text/javascript">
var myDropzone = new Dropzone("div#myDrop", {
    url: "photos/post",
    autoProcessQueue: false,
    uploadMultiple: true,
    addRemoveLinks: true,
    parallelUploads:3,
    maxFiles : 3,       
});

$('#post-btn').on('click',function(){        
     myDropzone.processQueue();
});

But using this code I can only post the image not the title and location. How can I post the the title and location values with the upload information ?

  • 写回答

1条回答 默认 最新

  • duanmeng1862 2015-07-27 15:33
    关注

    You can check out http://www.dropzonejs.com/#tips

    myDropzone.on("sending", function(file, xhr, formData) {
      // Will send the filesize along with the file as POST data.
      formData.append("filesize", file.size);
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集