workout the javascript part to show image preview