Bu html5 dosya yükleyici eklentisi üzerinde çalışıyorum ama anlayamadığım ve düzeltemediğim Google Chrome üzerinde bir hata var. Firefox'ta iyi çalışıyor. Chrome dosya yükleme hatası: on değişiklik olayı aynı dosya ile iki kez yürütülmeyecek
sorun
Eğer masaüstünüzden aynı dosyayı iki kez yükleyemezsiniz olmasıdır. İlk seçeneğini tıklatın ve masaüstünüzden bir dosya yüklemek için OK vurduğunda, bu .button-1' örneğin bir mesaj uyarı olmalıdır - tıkladığınızda hangi yükle düğmesi bağlıdır.
yeniden aynı dosyayı yüklemeye çalışırsa, bu kod satırı artık yürütülmez,
$(".upload-file",object_parent).change(function() {
...
...
alert($cm.selector);
});
bu eklenti nelerin yanlış gittiğini biliyor musunuz?
(function($){
// Attach this new method to jQuery
$.fn.extend({
// This is where you write your plugin's name
upload_file_html5: function(options) {
// Set the default values, use comma to separate the settings, example:
var defaults = {
objectSuperparent: '.media'
}
var options = $.extend(defaults, options);
var o = options;
var $cm = this.click(function(e){
// <a> button is the object in this case.
var object = $(this);
// Get other info from the element belong to this object group.
var object_href = object.attr('href');
var object_parent = object.parent();
alert($cm.selector);
// Trigger the click event on the element.
// Due to security policies triggering click on the input type=file is not allowed/supported in some browsers and Opera is one of them.
//$('input[type=file]').trigger('click'); // or:
$(".upload-file",object_parent).click();
return false;
});
// Trigger ajax post when ever the file is changed by the user.
var $cm_2 = $(".upload-file").change(function(){
// <input> is the object in this case.
var object = $(this);
var object_form = object.parent();
var object_superparent = object.parents(o.objectSuperparent);
var path_config = $($cm.selector,object_superparent).attr('href');
var path_post = object_form.attr('action');
alert($cm.selector);
//alert(path_config);
....
....
});
}
});
})(jQuery);
O Chrome'da Tamam çalışıyordu ama sadece muhtemelen Krom benim makineye bir son sürümünü güncelledi, son zamanlarda başarısız oldu ve bu güncelleştirme hata neden olur?
teşekkürler. O zaman onchange olayını kullanmamalıyım?veya aynı dosyayı yükleyebilmem için herhangi bir şekilde yapabilir miyim? – laukok
bir çalışma çözümü için aşağıdaki @ fundon [cevap] (https://stackoverflow.com/a/11280864/2024242) aşağıya bakın –