Created
September 4, 2014 10:16
-
-
Save morontt/c335bddffff3b0b3351e to your computer and use it in GitHub Desktop.
JavaScript file upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function () { | |
| $('#attachment-field').change(function () { | |
| var file = this.files[0]; | |
| //image file only | |
| if (file.type.match(/^image\//)) { | |
| var request = new XMLHttpRequest(); | |
| request.open('POST', '/upload/path'); | |
| request.send(new FormData(document.getElementById('form-xyz'))); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment