Ето една красота от този месец. Това е орязаната версия на Simple AJAX Uploader, в пълната се генерира и HTMLa с всички форми и бутони. Има и Advanced AJAX Uploader
var uploader = new ss.SimpleUpload(
{
button: btn,
url: pluginUrl + 'includes/save_image.php',
progressUrl: pluginUrl + 'includes/uploadProgress.php',
name: 'imgfile',
multiple: true,
maxUploads: 2,
maxSize: 200000,
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'tif', 'tiff'],
accept: 'image/*',
hoverClass: 'btn-hover',
focusClass: 'active',
disabledClass: 'disabled',
responseType: 'json',
checkProgressInterval: 50,
onExtError: function (filename, extension)
{
alert(filename + ' is not a permitted file type.' + "\n\n" + 'Only PNG, JPG, TIFF and GIF files are allowed.');
},
onSizeError: function (filename, fileSize)
{
alert(filename + ' is too big. (200M max file size)');
},
onProgress: function (pct)
{
$("#divProgressBar").animate
(
{
"width" : (pct - 2) * 3 + "px"
},
50,
function ()
{
$("#divProgressBar")
.text(pct + "%")
.css({"padding-left": "6px"});
});
},
onSubmit: function (filename, ext)
{
$("#upload_placeholder, #upload_result").hide();
$("#upload_wait").show();
},
startXHR: function ()
{
var abort = document.createElement('button');
abort.className = 'btn btn-sm btn-info';
abort.innerHTML = 'Cancel';
this.setAbortBtn(abort, true);
},
onComplete: function (filename, response)
{
$("#divProgressBar")
.width(0)
.text("")
.css({"padding-left": "0px"});
if (!response)
{
alert('Unable to upload file');
return;
}
if (response.success === true)
{
Canvas.resetCanvas();
imgInfo = response.file;
$("#imgPrint, #imgPrint2").attr("src", pluginUrl + "cache/" + imgInfo.thumbnail.fullname);
$("#print_top, #print_left, #print_right, #print_bottom").css(
{
"background-image": pluginUrl + "cache/" + imgInfo.thumbnail.fullname,
"background-color": "none"
});
$("#upload_wait").hide();
$("#upload_result").show();
Canvas.slideTo(2);
Canvas.checkDPI();
}
else
{
if (response.msg)
{
errBox.innerHTML = response.msg;
}
else
{
errBox.innerHTML = 'Unable to upload file';
}
}
}
});
p.s. Не ми се рови из архивите но ако се декларира с всички ивенти, ставаше около 10k файл.Редактирано от croesus на 29.04.14 01:47.
|