Skip to main content

Assuming you are using jQuery, I have following solution for you (sorry for the code formatting) :-->.

 $(document).ready(function(){  $('input[type=file]').on('change', setImage); 

});

}); function setImage(file)   {   if(document.all) 

{

document.getElementById('prevImage').src = file.value;

}

else{ document.getElementById('prevImage').src = file.files.item(0).getAsDataURL();

}

 { document.getElementById('prevImage').src = file.value; } else {  document.getElementById('prevImage').src = file.files.item(0).getAsDataURL();  } if(document.getElementById('prevImage').src.length > 0)    {  document.getElementById('prevImage').style.display = 'block';  } } 

}

Assuming you are using jQuery, I have following solution for you (sorry for the code formatting) :-->

 $(document).ready(function(){ $('input[type=file]').on('change', setImage); 

});

function setImage(file) {   if(document.all) 

{

document.getElementById('prevImage').src = file.value;

}

else{ document.getElementById('prevImage').src = file.files.item(0).getAsDataURL();

}

 if(document.getElementById('prevImage').src.length > 0)    document.getElementById('prevImage').style.display = 'block'; 

}

Assuming you are using jQuery, I have following solution for you.

$(document).ready(function(){  $('input[type=file]').on('change', setImage); }); function setImage(file)   { if(document.all)  { document.getElementById('prevImage').src = file.value; } else {  document.getElementById('prevImage').src = file.files.item(0).getAsDataURL();  } if(document.getElementById('prevImage').src.length > 0) {  document.getElementById('prevImage').style.display = 'block';  } } 
Source Link
rt2800
  • 3.1k
  • 2
  • 22
  • 26

Assuming you are using jQuery, I have following solution for you (sorry for the code formatting) :-->

 $(document).ready(function(){ $('input[type=file]').on('change', setImage); 

});

function setImage(file) { if(document.all) 

{

document.getElementById('prevImage').src = file.value;

}

else{ document.getElementById('prevImage').src = file.files.item(0).getAsDataURL();

}

 if(document.getElementById('prevImage').src.length > 0) document.getElementById('prevImage').style.display = 'block'; 

}