I want to show preview of an image before it is uploaded. I have found a partial solution that works for ie6 and firefox, and havent yet tested it in ie7 or ie8. But i want
you can use blow function. tested on IE7+ and Firefox and chrome
function loadname(img, previewName){
var isIE = (navigator.appName=="Microsoft Internet Explorer");
var path = img.value;
var ext = path.substring(path.lastIndexOf('.') + 1).toLowerCase();
if(ext == "gif" || ext == "jpeg" || ext == "jpg" || ext == "png" )
{
if(isIE) {
$('#'+ previewName).attr('src', path);
}else{
if (img.files[0])
{
var reader = new FileReader();
reader.onload = function (e) {
$('#'+ previewName).attr('src', e.target.result);
}
reader.readAsDataURL(img.files[0]);
}
}
}else{
incorrect file type
}
}