title: jQuery fileupload create form dynamiclly and send to s3
body: <p>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:</p>
  
  <ol>
  <li>create db object for file</li>
  <li>create dynamiclly form</li>
  <li>attach one file from fileupload to the created form</li>
  <li><p>send it via ajax to s3</p>
  
  <pre><code>add: (event, data) -&gt;
  # 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) -&gt;
              # now when object in db has been created i want to send a file
              s3Data = retdata
              s3Form = $("&lt;form&gt;", {
                  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("&lt;input type=\"hidden\" name=\"#{key}\" value=\"#{value}\"/&gt; ")
  
              # 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()
  </code></pre></li>
  </ol>
  
  <p>How to copy attached file to one form to the second form ?</p>