我对此代码有疑问:
function handleFileSelect(evt) {
evt.stopPropagation();
evt.preventDefault(); // stop default
console.log('ejecutado handleFileSelects')
var divOrigen = evt.target.parentNode; //get the div of the input
var divDestino = $(divOrigen).find('img'); //get the div for preview the img
var inputDestino = $(divOrigen).find('input[type="file"]'); // the input file
var files = evt.target.files; //get files in array
if (files.length) {
for (var i = 0, f; f = files[i]; i++) {
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
reader.onload = (function (theFile) {
return function (e) {
$(divDestino).attr('src', e.target.result); //read files content to preview in div
};
})(f);
reader.readAsDataURL(f);
}
$(inputDestino).popover('destroy');
} else {
evt.stopPropagation();
evt.preventDefault();
$(inputDestino).popover('show');
console.log('files is empty');
$(divDestino).attr('src', '/images/index/publicacion/dragAndDropHere.png');
}
}
此代码更改div
的背景。 div
的目的是预览输入文件的图像。在Opera,Firefox,Internet Explorer和Safari中,它运行良好,但是当我在Android平板电脑上试用它时,没有任何反应。有没有类似于Firebug for Android的工具?或者我可以用于Android平板电脑的任何框架?
答案 0 :(得分:1)
尝试从图像源中删除第一个/,而不是
$(divDestino).attr('src', '/images/index/publicacion/dragAndDropHere.png');
你有
$(divDestino).attr('src', 'images/index/publicacion/dragAndDropHere.png');