Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JS file upload.
<script>
var form = $('#attach-local-doc-form');
/*
* Note that variable `data` will not show anything due to hidden properties.
* It's purpose is to be passed to the server for parsing.
*/
var data = new FormData(form.get(0));
var fileNames = documentData.getAll("userfile").map(function (file) {
return file.name;
});
/*
* Now, type this in the console:
* Array.from(data.entries())
* This will list the data object of each file.
*/
</script>
<form id="attach-local-doc-form" enctype="multipart/form-data">
<label>Attachment</label>
<input type="file" multiple name="userfile">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.