UNPKG

simpapp-phonegap-file-upload

Version:

jQuery based file upload

61 lines (55 loc) 1.8 kB
# jQuery File Upload <p>By <b>Theramore</b> at <a href="http://simpapp.ro" target="_blank">simpapp.ro</a></p> <p><b>For questions and more visit the </b> at <a href="http://forum.simpapp.ro/index.php/js-file-upload/" target="_blank">Dev Forum!</a></p> <h3>Mainly created for Android & iOS file upload</h3> <h2>This is not click bait! This library works on Phonegap/Cordova, no permissions required and easy to use.</h2> ### Prerequisites jQuery is required. If not included will automatically load jQuery.min from Google Hosted Libraries ### Installing Just include the simpapp.js file as following and use after pageload event : ``` <!DOCTYPE HTML> <html> <head> <title>File Upload Example</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> </head> <body> <div> <span id="upload-progress">0</span> <input type="file" name="img" id="image" multiple /> <button class="" onclick="submit();">Upload</button> </div> </body> <script type="text/javascript"> function submit() { var opts = { multiple: true }; console.log('file submited'); simp.init("http://forum.simpapp.ro/testup.php", opts); simp.doUpload(function (data) { console.log(data); alert('uploaded'); },function (err) { console.log(err); alert('failed'); },function onProgress(percent) { $('#upload-progress').html(percent + '%'); }); } </script> <script type="text/javascript" src="simpapp.js"></script> </html> ``` ``` opts = { multiple: false, //Inputs have "multiple" tag progress: true, //if you want the upload to return percentage inputName: [], // for multiple file inputs, leave blank for default. }; ```