Html5 drag and drop files - download when submitting the entire form

Can drag and drop files be included in a form? There are many options for asynchronous loading.

Is it possible to write file data and include it in the form field?

I use Rails as my server, so ideally, the data for the image will follow a form similar to the following:

<form multipart='multipart' >
  <select name='files[type_id]'>
     ...
     ...
  </select>
  <!-- FILE DATA ?  -->
  <div id="file_drop_spot">

  </div>

</form>
+5
source share
1 answer

I found this problem on it: drag and drop files to standard html file

, , . , ajax. , , .

- :

<form id="form">
     <input type="text" name="someText"></input>
     <input id="submitButton" type="submit" onclick="uploadFile()"></input>
</form>

javascript:

function uploadFile() {

    document.getElementById("submitButton").disabled = true;
    // Some ajax code to upload the file and then on the success:
    success: function() {

        document.getElementById("form").submit();

    }
    return false; // Prevent the form from submitting

}
0

All Articles