Created
November 20, 2015 22:16
-
-
Save sysnajar/181a21d88d8161592d76 to your computer and use it in GitHub Desktop.
File upload snippet
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
| <input type='file' id='fileUpload' style='display:none'> <---- 1. file input | |
| <li style='display:inline'> <i class="clip-folder-upload" onclick='uploadAttachment(this);'></i> </li> <--- 2. icon trigger | |
| <script src="assets/js/ajaxfileupload.js"></script> <--3. js file | |
| function upload() | |
| { | |
| var id = 'file'; | |
| var val = $('#'+id).val(); | |
| if(val=='')return; | |
| $('#uploadDiv').hide(); | |
| $('#uploadingDiv').show(); | |
| $.ajaxFileUpload | |
| ( | |
| { | |
| url:'upload/map_attr.htx', | |
| secureuri:false, | |
| fileElementId:id, | |
| dataType: 'json', | |
| success: function (data, status) | |
| { | |
| if(typeof(data.error) != 'undefined') | |
| { | |
| onUploadError(data.error); | |
| }else | |
| { | |
| alert('success'); | |
| showUpload(); | |
| } | |
| }, | |
| error: function (data, status, e) | |
| { | |
| onUploadError(e); | |
| } | |
| } | |
| ); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment