10
bluimp jQuery-File-Upload-plugin kullanıyorum. Bazı dosyaları seçmek ve yüklemek hiç sorun değil, ancak sayfayı yenilemeden başka bir dosya yüklemek istediğimde, ilk olarak tekrar yükleniyor. Sorum şu, yüklendikten sonra dosyaları nasıl "çözemiyorum". İşte benim SourcecodeBir dosya sadece Blueimp dosya yükleme eklentisi ile nasıl yüklenir?
JavaScript geçerli:
$('#MappeFile').fileupload({
dataType : 'json',
autoUpload : false,
maxNumberOfFiles : undefined,
maxFileSize : 6000000,
minFileSize : undefined,
acceptFileTypes : /.+$/i,
url : "/ajax/UploadFile.php",
add : function(e, data) {
$("#testUploadButton").on("click", function() {
$('#progress .bar').show();
if ($.browser.msie && parseInt($.browser.version, 10) < 10) {
$('#progress .bar').css({
"background" : "url(images/progressbar.gif) no-repeat",
"width" : "100%"
})
} else {
$('#progress .bar').css({
'background-color' : "#2694E8",
'width' : '0%'
});
}
data.submit();
})
},
change : function(e, data) {
$.each(data.files, function(index, file) {
console.info('Selected file: ' + file.name);
filesCount++;
});
},
drop: function(e, data) {
$.each(data.files, function(index, file) {
console.info('Selected file: ' + file.name);
filesCount++;
});
},
done : function(e, data) {
$.each(data.result, function(index, file) {
vOutput = "<tr>";
vOutput += "<td>" + file + "</td>";
vOutput += "<tr>";
$("#MappeFileListe").append(vOutput);
filesUploaded++;
if (filesCount == filesUploaded) {
filesUploaded = 0;
filesCount=0;
$('#progress .bar').hide();
}
});
},
progressall : function(e, data) {
var progress = parseInt(data.loaded/data.total * 100, 10);
$('#progress .bar').css('width', progress + '%');
}
});
HTML:
<div id="KundeMappe">
<form id="MappeFile">
<input type="file" id="MappeFileSelect" name="files[]" data-url="ajax/UploadFile.php" multiple/>
<div id="progress">
<div class="bar" style="width: 0%;"></div>
</div>
<input type="button" class="neuButton" value="upload" id="testUploadButton"/>
</form>
<table id="MappeFileListe"></table>
</div>
Aynı problemim var. Ancak çözümünüzle, bellek ayırmaya devam eden diğer tüm istekleri bastırır. Seçilen dosyaların yükleme sırasına eklenmesini önlemek için dosya sayısı nasıl kısıtlanır? 'MaxNumberOfFiles: 1' ayarı benim için çalışmıyor. – static
, "$ (" # testUploadButton ") ayarını yeni" $ ("# testUploadButton") 'dan önce "(tıklat"), işlev() {...} 'ye ayarlamaktan daha iyidir. ? – static
Sizin çözümünüz DOĞRU cevap olarak görünmüyor, ama benim için hile çok teşekkür etti – VahidNaderi