function vpb_multiple_file_uploader(vpb_configuration_settings) { this.vpb_settings = vpb_configuration_settings; this.vpb_files = ""; this.vpb_browsed_files = [] var self = this; var vpb_msg = "Sorry, your browser does not support this application. Thank You!"; //Get all browsed file extensions function vpb_file_ext(file) { return (/[.]/.exec(file)) ? /[^.]+$/.exec(file.toLowerCase()) : ''; } /* Display added files which are ready for upload */ //with their file types, names, size, date last modified along with an option to remove an unwanted file vpb_multiple_file_uploader.prototype.vpb_show_added_files = function(vpb_value) { this.vpb_files = vpb_value; if(this.vpb_files.length > 0) { var vpb_added_files_displayer = vpb_file_id = ""; for(var i = 0; i 1) { if (((vpb_fileSize / 1024) / 1024) > 1) { vpb_fileSize = (Math.round(((vpb_fileSize / 1024) / 1024) * 100) / 100); var vpb_actual_fileSize = vpb_fileSize + " GB"; } else { vpb_fileSize = (Math.round((vpb_fileSize / 1024) * 100) / 100) var vpb_actual_fileSize = vpb_fileSize + " MB"; } } else { vpb_fileSize = (Math.round(vpb_fileSize * 100) / 100) var vpb_actual_fileSize = vpb_fileSize + " KB"; } //Check and display the date that files were last modified var vpb_date_last_modified = new Date(this.vpb_files[i].lastModifiedDate); var dd = vpb_date_last_modified.getDate(); var mm = vpb_date_last_modified.getMonth() + 1; var yyyy = vpb_date_last_modified.getFullYear(); var vpb_date_last_modified_file = dd + '/' + mm + '/' + yyyy; //File Display Classes if( vpb_class == 'vpb_blue' ) { var new_classc = 'vpb_white'; } else { var new_classc = 'vpb_blue'; } if(typeof this.vpb_files[i] != undefined && this.vpb_files[i].name != "") { //Check for the type of file browsed so as to represent each file with the appropriate file icon if( vpb_file_to_add == "jpg" || vpb_file_to_add == "JPG" || vpb_file_to_add == "jpeg" || vpb_file_to_add == "JPEG" || vpb_file_to_add == "gif" || vpb_file_to_add == "GIF" || vpb_file_to_add == "png" || vpb_file_to_add == "PNG" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "doc" || vpb_file_to_add == "docx" || vpb_file_to_add == "rtf" || vpb_file_to_add == "DOC" || vpb_file_to_add == "DOCX" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "pdf" || vpb_file_to_add == "PDF" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "txt" || vpb_file_to_add == "TXT" || vpb_file_to_add == "RTF" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "php" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "css" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "js" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "html" || vpb_file_to_add == "HTML" || vpb_file_to_add == "htm" || vpb_file_to_add == "HTM" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "setup" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "video" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "real" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "psd" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "fla" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "xls" || vpb_file_to_add == "xlsx" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "swf" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "eps" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "exe" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "binary" ) { vpb_file_icon = ''; } else if( vpb_file_to_add == "zip" ) { vpb_file_icon = ''; } else { vpb_file_icon = ''; } var split = this.vpb_files[i].name.split('.'); var filename = split[0]; var extension = split[1]; if (filename.length > 15) { filename = filename.substring(0, 10)+'[...]'; } var result = filename + '.' + extension; //Assign browsed files to a variable so as to later display them below vpb_added_files_displayer += '
'+vpb_file_icon+' '+result+'
Uploadbereit
'+vpb_actual_fileSize+'
Entfernen'; } } //Display browsed files on the screen to the user who wants to upload them $("#add_files").append(vpb_added_files_displayer); $("#added_class").val(new_classc); } } //File Reader vpb_multiple_file_uploader.prototype.vpb_read_file = function(vpb_e) { if(vpb_e.target.files) { self.vpb_show_added_files(vpb_e.target.files); self.vpb_browsed_files.push(vpb_e.target.files); } else { alert('Sorry, a file you have specified could not be read at the moment. Thank You!'); } } function addEvent(type, el, fn){ if (window.addEventListener){ el.addEventListener(type, fn, false); } else if (window.attachEvent){ var f = function(){ fn.call(el, window.event); }; el.attachEvent('on' + type, f) } } //Get the ids of all added files and also start the upload when called vpb_multiple_file_uploader.prototype.vpb_starter = function() { if (window.File && window.FileReader && window.FileList && window.Blob) { var vpb_browsed_file_ids = $("#"+this.vpb_settings.vpb_form_id).find("input[type='file']").eq(0).attr("id"); document.getElementById(vpb_browsed_file_ids).addEventListener("change", this.vpb_read_file, false); document.getElementById(this.vpb_settings.vpb_form_id).addEventListener("submit", this.vpb_submit_added_files, true); } else { alert(vpb_msg); } } //Call the uploading function when click on the upload button vpb_multiple_file_uploader.prototype.vpb_submit_added_files = function(){ self.vpb_upload_bgin(); } //Start uploads vpb_multiple_file_uploader.prototype.vpb_upload_bgin = function() { if(this.vpb_browsed_files.length > 0) { for(var k=0; k'); $("#remove"+ids).html('
Uploading...
'); }, success:function(response) { // alert('Wert: '+response); setTimeout(function() { var response_brought = response.indexOf(ids); if ( response_brought != -1) { $("#uploading_"+ids).html('
Vollständig
'); $("#remove"+ids).html('
Hochgeladen
'); } else { var fileType_response_brought = response.indexOf('file_type_error'); if ( fileType_response_brought != -1) { var filenamewithoutextension = response.replace('file_type_error&', '').substr(0, response.replace('file_type_error&', '').lastIndexOf('.')) || response.replace('file_type_error&', ''); var fileID = filenamewithoutextension.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ''); $("#uploading_"+fileID).html('
Invalid File
'); $("#remove"+fileID).html('
Abgebrochen
'); } else { var filesize_response_brought = response.indexOf('file_size_error'); if ( filesize_response_brought != -1) { var filenamewithoutextensions = response.replace('file_size_error&', '').substr(0, response.replace('file_size_error&', '').lastIndexOf('.')) || response.replace('file_size_error&', ''); var fileID = filenamewithoutextensions.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ''); $("#uploading_"+fileID).html('
Exceeded Size
'); $("#remove"+fileID).html('
Abgebrochen
'); } else { var general_response_brought = response.indexOf('general_system_error'); if ( general_response_brought != -1) { alert('Sorry, the file was not uploaded...'); } else { /* Do nothing */} } } } if (file_counter+1 < file.length ) { self.vasPLUS(file,file_counter+1); } else {} },2000); } }); } } else { alert('Sorry, this system could not verify the identity of the file you were trying to upload at the moment. Thank You!'); } } this.vpb_starter(); } function vpb_remove_this_file(id, filename) { if(confirm('If you are sure to remove the file: '+filename+' then click on OK otherwise, Cancel it.')) { $("#vpb_removed_files").append(''); $("#add_fileID"+id).slideUp(); } return false; }