0

I'd like to pre-visualize an image in a image box before save it in a directory. How can i do this, i use a checkbox to see if the user wants to pre-visualize or not because i dont find another way to do this without a checkbox. I use file upload to upload the image.

string serverFileName = "";
serverFileName = Path.GetFileName(Upload.PostedFile.FileName);
Upload.PostedFile.SaveAs(MapPath("~/fotosPerfil/") + serverFileName);

i use this piece of code to save the image.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Severiano
  • 1,083
  • 3
  • 25
  • 54
  • You need JavaScript. A good easy way is to examine the Wikipedia upload form – Cole Tobin May 20 '12 at 16:12
  • Can JavaScript reference the image file in the client file system? Or can the DOM reference such a file? – John Saunders May 20 '12 at 19:53
  • 1
    @Diogo: are the images so large that you can't upload them first to a temporary location on the server before asking the user if they want the image permanently saved? – John Saunders May 20 '12 at 19:54

1 Answers1

1

I think this post is exactly what you need to implement. Check out Ivan's solution.

Yes, indeed you can read the path selected by the user and display the image in an <img> tag, all client-side prior to uploading.

Community
  • 1
  • 1
Pablo Romeo
  • 11,298
  • 2
  • 30
  • 58