Im working on image preview before uploading with JQuery, it’s working in chrome, and opera but it’s not working in Firefox. Here is the code.
(function() {
var result = document.getElementById('pnlZoom'),
load = function(e) {
e.preventDefault();
window.loadImage(
(e.dataTransfer || e.target).files[0],
function(img) {
var source = img.src;
$("#img").attr("src",source);
alert("Image source is: "+img.src);
}
);
};
document.ondragover = function(e) {
e.preventDefault();
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed = 'copy';
};
document.ondrop = load;
document.getElementById('file-input').onchange = load;
} ());
can anyone please help me to find the problem with src in Firefox and IE . or any other better working solution in all five major browsers?
If you can find the image without a problem then just use plain DOM methods:
If you cannot find img then you need to do that first.