Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($)
- {
- $.fn.upload = function()
- {
- return this.each(function()
- {
- $(this).attr("action", "");
- $(this).attr("target", "upload-frame");
- $(this).after("<iframe id='upload-frame' name='uploadFrame' src='#' style='display:none'></iframe>");
- $(this).submit(function getProgress () {
- $(this).hide(300);
- $(this).append("<div id='upload-progress' style='display: none;'>\n\
- <div id='upload-progress-bar'></div>\n\
- <div id='upload-progress-text'></div>\n\
- </div>");
- $("#upload-progress").show(300);
- $.ajax({
- type: "POST",
- url: "verifUpload.php",
- data: "keyFile="+$(this).children("[name=APC_UPLOAD_PROGRESS]").val(),
- success: function (msg) {
- if(msg != "false") {
- var data = $.parseJSON(msg);
- var file = data.filename;
- var total = data.total;
- var done = data.current;
- var percent = Math.round(done / total * 100) + '%';
- $("#upload-progress-text").text("Fichier : " + file);
- $("#upload-progress-bar").text(percent);
- $("#upload-progress-bar").animate({width: percent}, 100);
- if(data.done != 1) {
- getProgress();
- }
- else {
- $("#upload-progress-text").append("<br/>Vitesse d'envoi : " + Math.round(data.rate / 1000) + " ko/s")
- }
- }
- else {
- getProgress();
- }
- }
- });
- });
- });
- };
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment