简体   繁体   中英

jQuery fileupload create form dynamiclly and send to s3

i would like to upload files added through jquery-fileupload via ajax send form. My problem is when i'm trying to overwrite add() function i want to:

  1. create db object for file
  2. create dynamiclly form
  3. attach one file from fileupload to the created form
  4. send it via ajax to s3

     add: (event, data) -> # send each file to the s3 for file in data.files $.ajax({ url: "/attachments", data: { ... } type: "POST", processData: false, dataType: "json", async: false, success: (retdata) -> # now when object in db has been created i want to send a file s3Data = retdata s3Form = $("<form>", { id: "avatar-form", action: "#{s3Data.schema}://#{s3Data.host}", method: s3Data.method, enctype: "multipart/form-data", acceptCharset: "UTF-8" }) # create inputs for files for key, value of s3Data.formdata s3Form.append("<input type=\\"hidden\\" name=\\"#{key}\\" value=\\"#{value}\\"/> ") # here i have my file object from the loop and also access to the # data.form, which is jquery file upload form # how to extract files from form, and append it to the new s3Form s3Form.ajaxForm({}) s3Form.submit() 

How to copy attached file to one form to the second form ?

我猜输入fileupload对象可以通过js访问: http : //www.w3schools.com/jsref/dom_obj_fileupload.asp但是,表格可能需要先附加到文档上。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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