How to display image preview before uploading using JavaScript?

December 2, 2015


Amazing JavaScript trick to preview image before uploading.

  • Level: Hard
  • Author: Er Abhinav

This an amazing JS trick to show image preview before display.It might be very useful in many cases and will definitely save an extra server hit. So first you need a basic html structure with one file upload  and one image tag to display preview.

HTML file:


JS File:

Its just a simple hack , extremely useful. Please comment below for any other query. Also share this post if it was somewhat helpful to you.


Have your say