It looks like you're new here. If you want to get involved, click one of these buttons!
if (jQuery) {
(function($) {
$.extend($.fn, {
uploadify : function(p) {
$(this).each(function() {
set = $.extend({
'id' : $(this).attr('id'), /* The ID of the object being Uploadified */
'uploader' : 'uploadify.swf', /* The path to the uploadify swf file */
'script' : 'uploadify.php', /* The path to the uploadify backend upload script */
'expressInstall' : null, /* The path to the express install swf file */
'folder' : '', /* The path to the upload folder */
'height' : 30, /* The height of the flash button */
'width' : 110, /* The width of the flash button */
'wmode' : 'opaque', /* The wmode of the flash file */
'scriptAccess' : 'sameDomain', /* Set to \"always\" to allow script access across domains */
'fileDataName' : 'Filedata', /* The name of the file collection object in the backend upload script */
'method' : 'POST', /* The method for sending variables to the backend upload script */
'queueSizeLimit' : 2, /* The maximum size of the file queue */
'simUploadLimit' : 1, /* The number of simultaneous uploads allowed */
'queueID' : false, /* The optional ID of the queue container */
'displayData' : 'percentage', /* Set to \"speed\" to show the upload speed in the default queue item */
'onInit' : function() {}, /* Function to run when uploadify is initialized */
'onSelect' : function() {}, /* Function to run when a file is selected */
'onQueueFull' : function() {}, /* Function to run when the queue reaches capacity */
'onCheck' : function() {}, /* Function to run when script checks for duplicate files on the server */
'onCancel' : function() {}, /* Function to run when an item is cleared from the queue */
'onError' : function() {}, /* Function to run when an upload item returns an error */
'onProgress' : function() {}, /* Function to run each time the upload progress is updated */
'onComplete' : function() {}, /* Function to run when an upload is completed */
'onAllComplete' : function() {} /* Functino to run when all uploads are completed */
}, p);
var pagePath = location.pathname;
pagePath = pagePath.split('/');
pagePath.pop();
pagePath = pagePath.join('/') + '/';
var data = {};
data.uploadifyID = set.id;
data.pagepath = pagePath;
var ocs = {
'buttonclass' : 'uploadify-button ui-corner-all',
'buttonicon' : 'icons icon-import',
'buttondefault' : 'ui-state-default',
'buttonhover' : 'ui-state-hover',
'filename' : 'filename',
'iconcancel' : 'ui-icon ui-icon-circle-close',
'item' : 'item ui-widget-content',
'itemcancel' : 'cancel',
'percentage' : 'percentage',
'progress' : 'ui-progressbar-value',
'progresslabel' : 'ui-progressbar-label',
'progressbar' : 'ui-progressbar',
'uploadify' : 'uploadify'
};
var str = {
'cancel' : 'Abbrechen',
'completed' : 'Fertig',
'filereplace' : 'Die Datei {file} existiert schon.\nSoll die Datei erstezt werden?',
'error' : 'Fehler',
'remove' : 'Entfernen',
'upload' : '\u00DCbertragen',
'uploadfile' : 'Datei \u00FCbertragen',
'uploadfiles' : 'Dateien \u00FCbertragen',
'maxfiles' : 'Sie k\u00F6nnen maximal {num} Dateien auf gleichzeitig \u00FCbertragen.'
};
if (set.buttonImg) {
data.buttonImg = escape(set.buttonImg);
}
if (set.buttonText) {
data.buttonText = escape(set.buttonText);
}
if (set.rollover) {
data.rollover = true;
}
data.script = set.script;
data.folder = escape(set.folder);
if (set.scriptData) {
var scriptDataString = '';
for (var name in set.scriptData) {
scriptDataString += '&' + name + '=' + set.scriptData[name];
}
data.scriptData = escape(scriptDataString.substr(1));
}
if (set.cssButton) {
set.wmode = 'transparent';
}
data.width = set.width;
data.height = set.height;
data.wmode = set.wmode;
data.method = set.method;
data.queueSizeLimit = set.queueSizeLimit;
data.simUploadLimit = set.simUploadLimit;
if (set.hideButton || set.cssButton) {
data.hideButton = true;
}
if (set.fileDesc) {
data.fileDesc = set.fileDesc;
}
if (set.fileExt) {
data.fileExt = set.fileExt;
}
if (set.multi) {
data.multi = true;
}
if (set.auto) {
data.auto = true;
}
if (set.sizeLimit) {
data.sizeLimit = set.sizeLimit;
}
if (set.checkScript) {
data.checkScript = set.checkScript;
}
if (set.fileDataName) {
data.fileDataName = set.fileDataName;
}
if (set.queueID) {
data.queueID = set.queueID;
}
if (set.onInit() !== false) {
var idx = $(this).attr('id');
$(this).css('display', 'none');
$(this).after('<div id=\"' + idx + '_uploader\"><\/div>');
swfobject.embedSWF(set.uploader, set.id + '_uploader',
set.width, set.height,
'9.0.24', set.expressInstall,
data, { 'quality' : 'high', 'wmode' : set.wmode, 'allowScriptAccess' : set.scriptAccess }
);
if (set.queueID == false) {
$('#' + idx + '_uploader').after('<div id=\"' + idx + '_queue\"><\/div>');
}
if (set.cssButton) {
$(this).after('<span id=\"' + idx + '_cssbutton\" class=\"' + ocs.buttonclass + ' ' + ocs.buttondefault + '\"><span class=\"' + ocs.buttonicon + '\"></span>' + ( (data.multi) ? str.uploadfiles : str.uploadfile ) + '</span>');
var tmp = $('#' + idx + '_cssbutton').offset();
$('#' + idx + '_uploader').css({
'display' : 'block',
'position' : 'absolute',
'left' : tmp.left + 'px',
'top' : tmp.top + 'px',
'width' : $('#' + idx + '_cssbutton').outerWidth(),
'height' : $('#' + idx + '_cssbutton').outerHeight()
}).hover(
function() {
$('#' + idx + '_cssbutton').removeClass(ocs.buttondefault).addClass(ocs.buttonhover);
},
function() {
$('#' + idx + '_cssbutton').removeClass(ocs.buttonhover).addClass(ocs.buttondefault);
}
);
}
idx = null; tmp = null;
}
if (typeof(set.onOpen) == 'function') {
$(this).bind('uploadifyOpen', set.onOpen);
}
$(this).bind('uploadifySelect', { 'action' : set.onSelect, 'queueID' : set.queueID }, function(e, i, f) {
if (e.data.action(e, i, f) !== false) {
var b = (Math.round(f.size / 1024 * 100) * .01), n = f.name, u = 'KB', x = $(this).attr('id'), q = '#' + x + '_queue';
if (b > 1000) {
b = Math.round((b *.001 * 100) * .01);
u = 'MB';
}
var p = b.toString().split('.');
if (p.length > 1) {
b = p[0] + '.' + p[1].substr(0,2);
} else {
b = p[0];
}
if (f.name.length > 20) {
n = f.name.substr(0, 20) + '...';
}
if (e.data.queueID) {
q = '#' + e.data.queueID;
}
$(q).append(
'<div class=\"' + ocs.item + '\" id=\"' + x + i + '\">'
+ '<div class=\"' + ocs.itemcancel + '\" id=\"' + x + i + '_cancel\" title=\"' + str.remove + '\"><span class=\"' + ocs.iconcancel + '\">' + str.remove + '<\/span><\/div>'
+ '<div class=\"' + ocs.progressbar + '\" id=\"' + x + i + '_progressbar\"><\/div>'
+ '<\/div>'
).attr({ 'className' : ocs.uploadify });
$('#' + x + i + '_cancel').click(function() {
$('#' + x).uploadifyCancel(i);
}).hover(
function() {
$(this).addClass('ui-state-hover');
},
function () {
$(this).removeClass('ui-state-hover');
}
);
$('#' + x + i + '_progressbar').progressbar({ value: 0 });
$('#' + x + i + '_progressbar').css({ 'width' : ($('#' + x + i).width() - 30) + 'px' });
$('#' + x + i + '_progressbar').append('<div class=\"' + ocs.progresslabel + '\"><span class=\"' + ocs.filename + '\" id=\"' + x + i + '_file\">' + n + ' (' + b + u + ')<\/span><span class=\"' + ocs.percentage + '\" id=\"' + x + i + '_percentage\"><\/span><\/div>');
$('#' + x + i + '_progressbar .' + ocs.progresslabel).css({ 'width' : $('#' + x + i + '_progressbar').innerWidth() + 'px' });
}
});
if (typeof(set.onSelectOnce) == 'function') {
$(this).bind('uploadifySelectOnce', set.onSelectOnce);
}
$(this).bind('uploadifyQueueFull', { 'action' : set.onQueueFull }, function(e, l) {
if (e.data.action(e, l) !== false) {
var m = str.maxfiles;
m = m.replace(/{num}/, l);
alert(m);
}
});
$(this).bind('uploadifyCheckExist', { 'action' : set.onCheck }, function(e, c, o, f, s) {
var postData = new Object();
postData = o;
postData.folder = pagePath + f;
if (s) {
for (var ID in o) {
var singleFileID = ID;
}
}
$.post(c, postData, function(data) {
for (var k in data) {
if (e.data.action(e, c, o, f, s) !== false) {
var m = str.filereplace;
m = m.replace(/{file}/, data[k]);
var r = confirm(m);
if (!r) {
document.getElementById($(e.target).attr('id') + '_uploader').cancelFileUpload(k, true,true);
}
}
}
if (s) {
document.getElementById($(e.target).attr('id') + '_uploader').startFileUpload(singleFileID, true);
} else {
document.getElementById($(e.target).attr('id') + '_uploader').startFileUpload(null, true);
}
}, 'json');
});
$(this).bind('uploadifyCancel', { 'action' : set.onCancel }, function(e, i, f, data, c) {
if (e.data.action(e, i, f, data, c) !== false) {
var s = (c == true) ? 0 : 250;
$('#' + $(this).attr('id') + i).fadeOut(s, function() { $(this).remove() });
}
});
if (typeof(set.onClearQueue) == 'function') {
$(this).bind('uploadifyClearQueue', set.onClearQueue);
}
var errorArray = [];
$(this).bind('uploadifyError', { 'action' : set.onError }, function(e, i, f, o) {
if (e.data.action(e, i, f, o) !== false) {
var fileArray = new Array(i, f, o);
errorArray.push(fileArray);
$('#' + $(this).attr('id') + i + '_percentage').text(str.error);
}
});
$(this).bind('uploadifyProgress', { 'action' : set.onProgress, 'toDisplay' : set.displayData }, function(e, i, f, data) {
if (e.data.action(e, i, f, data) !== false) {
$('#' + $(this).attr('id') + i + '_progressbar').progressbar('option', 'value', data.percentage); /* .css('width', data.percentage + '%'); */
if (e.data.toDisplay == 'percentage') {
displayData = data.percentage + '%';
}
if (e.data.toDisplay == 'speed') {
displayData = data.speed + 'KB/s';
}
if (e.data.toDisplay == null) {
displayData = ' ';
}
$('#' + $(this).attr('id') + i + '_percentage').text(displayData);
}
});
$(this).bind('uploadifyComplete', { 'action' : set.onComplete }, function(e, i, f, r, data) {
if (e.data.action(e, i, f, unescape(r), data) !== false) {
$('#' + $(this).attr('id') + i + '_percentage').text(str.completed);
$('#' + $(this).attr('id') + i).fadeOut(250, function() { $(this).remove()});
}
});
if (typeof(set.onAllComplete) == 'function') {
$(this).bind('uploadifyAllComplete', { 'action' : set.onAllComplete }, function(e, o) {
if (e.data.action(e, o) !== false) {
errorArray = [];
}
});
}
});
},
uploadifySettings : function(n, v, o) {
var rv = false;
$(this).each(function() {
if (n == 'scriptData' && v !== null) {
if (o) {
var scriptData = v;
} else {
var scriptData = $.extend(set.scriptData, v);
}
var scriptDataString = '';
for (var x in scriptData) {
scriptDataString += '&' + x + '=' + escape(scriptData[x]);
}
v = scriptDataString.substr(1);
}
rv = document.getElementById($(this).attr('id') + '_uploader').updateSettings(n, v);
});
if (v === null) {
if (n == 'scriptData') {
var rs = unescape(rv).split('&');
var ro = new Object();
for (var i = 0; i < rs.length; i++) {
var iSplit = rs[i].split('=');
ro[iSplit[0]] = iSplit[1];
}
rv = ro;
}
return rv;
}
},
uploadifyUpload : function(i) {
$(this).each(function() {
document.getElementById($(this).attr('id') + '_uploader').startFileUpload(i, false);
});
},
uploadifyCancel : function(i) {
$(this).each(function() {
document.getElementById($(this).attr('id') + '_uploader').cancelFileUpload(i, true, false);
});
},
uploadifyClearQueue : function() {
$(this).each(function() {
document.getElementById($(this).attr('id') + '_uploader').clearFileUploadQueue(false);
});
}
})
})(jQuery);
}.uploadify .cancel {
background-image: none !important;
float: right;
}
.uploadify .cancel .ui-icon, .uploadify .cancel.ui-state-hover .ui-icon {
cursor: pointer;
height: 16px !important;
width: 16px;
}
.uploadify .cancel .ui-icon { margin: 3px 3px 3px 3px; }
.uploadify .cancel.ui-state-hover .ui-icon { margin: 2px 2px 2px 2px; }
.uploadify .cancel.ui-state-hover { border: 1px solid #666666; }
.uploadify .item {
font-size: 11px;
margin-bottom: 5px;
padding: 10px;
width: 350px;
}
.uploadify .ui-progressbar {
position: relative;
}
.uploadify .ui-progressbar .ui-progressbar-label {
position: absolute;
left: 0px;
top: 0px;
}
.uploadify .ui-progressbar .ui-progressbar-label .filename {
float: left;
margin-left: 5px;
width: 50%;
}
.uploadify .ui-progressbar .ui-progressbar-label .percentage {
float: right;
margin-right: 5px;
text-align: right;
width: 20%;
}
.uploadify-button {
padding: 4px 4px 4px 20px;
position: relative;
}
.uploadify-button .ui-icon, .uploadify-button .icons {
left: 2px;
height: 20px;
margin-top: -9px;
position: absolute;
top: 50%;
width: 20px;
}<input type=\"file\" name=\"uploadify\" id=\"uploadify\" />
<p>
<button onclick=\"jQuery('#uploadify').uploadifyUpload()\">Start Upload</button>
<button onclick=\"jQuery('#uploadify').uploadifyClearQueue()\">Cancel All Uploads</button>
</p>
<div id=\"uplodifyqueue\" style=\"margin-top: 5px; float: left;\"></div>
<script type=\"text/javascript\">
$(document).ready(function() {
$(\"#uploadify\").uploadify({
'uploader' : 'swf/jquery-upload.swf',
'script' : 'upload.php',
'checkScript' : 'upload-check.php',
'folder' : 'uploads',
'auto' : false,
'multi' : true,
'cssButton' : true,
'queueID' : 'uplodifyqueue',
'fileExt' : '*.doc;*.rtf;*.pdf;*.zip',
'fileDesc' : 'Presse Texte',
});
});
</script>
Rapid-eraser said:Is there any working demo ?