开发者

Image upload functionality with preview

开发者 https://www.devze.com 2022-12-15 11:12 出处:网络
I have to implement an image upload functionality in asp.net. The method I have followed works like this :-

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开发者_如何学Python way to display the image in a <div> may be, rather than in an iframe which I think is far better than this approach.


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号