var all_files_load_done = new Array(); var msg_show; $(function(){ var ul = $('#upload ul'); $('#drop a').click(function(){ // Simulate a click on the file input button // to show the file browser dialog $(this).parent().find('input').click(); }); // Initialize the jQuery File Upload plugin $('#upload').fileupload({ // This element will accept file drag/drop uploading dropZone: $('#drop'), // This function is called when a file is added to the queue; // either via the browse button, or via drag/drop: add: function (e, data) { // Automatically upload the file once it is added to the queue var jqXHR = data.submit(); }, start:function(e, data){ all_files_load_done = new Array(); }, done:function(e, data){ var fname = data.files[0].name; var isin = fname.indexOf('zip'); if(isin>=0){ $.ajax({ url: 'extract.php', type: 'POST', async: true, data: { file_upload:data.files[0].name}, success: function(response){ parse_all_data(data.files[0].name); } }); } }, progressall: function (e, data) { $("#loader").html(""); var tpl = $('
  • '); // Add the HTML to the UL element data.context = tpl.appendTo(ul); tpl.find('input').knob(); var progress = parseInt(data.loaded / data.total * 100, 10); // Update the hidden input field and trigger a change // so that the jQuery knob plugin knows to update the dial data.context.find('input').val(progress).change(); if(progress==100){ msg_show = setTimeout(function() { $("#loader").html("

    Please wait while processing data...

    "); }, 1000); } } }); // Prevent the default action when a file is dropped on the window $(document).on('drop dragover', function (e) { e.preventDefault(); }); // Helper function that formats the file sizes function formatFileSize(bytes) { if (typeof bytes !== 'number') { return ''; } if (bytes >= 1000000000) { return (bytes / 1000000000).toFixed(2) + ' GB'; } if (bytes >= 1000000) { return (bytes / 1000000).toFixed(2) + ' MB'; } return (bytes / 1000).toFixed(2) + ' KB'; } function parse_all_data(fname){ $.ajax({ url: 'parse.php', type: 'POST', async: true, data: { file:fname }, success: function(response){ clearTimeout(msg_show); document.location = "download.php?filename="+fname; $("#loader").html("

    DONE

    "); } }); } });