簡體   English   中英

jQuery fileupload動態創建表單並發送到s3

[英]jQuery fileupload create form dynamiclly and send to s3

我想通過ajax發送表單上傳通過jquery-fileupload添加的文件。 我的問題是當我嘗試覆蓋add()函數時,我想:

  1. 為文件創建數據庫對象
  2. 動態創建表格
  3. 將文件上傳中的一個文件附加到創建的表單
  4. 通過ajax發送到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() 

如何將附件復制到一種形式到第二種形式?

我猜輸入fileupload對象可以通過js訪問: http : //www.w3schools.com/jsref/dom_obj_fileupload.asp但是,表格可能需要先附加到文檔上。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM