Ajay
Ajay

Reputation: 7428

Image upload functionality with preview

I have to implement an image upload functionality in asp.net. The method I have followed works like this :-

Submit a form containing an <input type='file'> element and set the target of the form to a named iframe[to give the impression of a Ajax request/response ]. The aspx file which this form is posted to, writes the image into the response as Reponse.Write("<img src='location'/>"); The image displayed is due for cropping (where i plan to use JCrop).

What I would like to know is : Is there another way to display the image in a <div> may be, rather than in an iframe which I think is far better than this approach.

Upvotes: 0

Views: 641

Answers (1)

JonathanK
JonathanK

Reputation: 3040

If you have or can get access to the 'location' value you certainly have everything you need to be able to add a div element to your response:

Response.Write("<div><img src='location'/></div>");

Or possibly use something like jQuery to simply set the content of an existing div:

$("#uploadedImage").html("<img src='location' />");

In your HTML document:

<div id="uploadedImage"></div>

Upvotes: 1

Related Questions