开发者

How can I pass a raw System.Drawing.Image to an .ashx?

开发者 https://www.devze.com 2023-01-02 02:02 出处:网络
I am developing an application that stores images as Base64 strings in xml files.I also want to allow the user to crop the image before saving it to the file, preferably all in memory without having t

I am developing an application that stores images as Base64 strings in xml files. I also want to allow the user to crop the image before saving it to the file, preferably all in memory without having to save a temp file, and then delete it afterwards. In order to display the newly uploaded image, I need 开发者_如何学运维to create a HTTP handler that I can bind the asp:Image to. The only examples for doing this online require passing the .ashx an ID and then pulling the image from a DB or other data store. Is it possible to somehow pass the raw data to the .ashx in order to get back the image?

Thanks,

Mike


Assuming that you never have a server-farm, you could put the image in session state.

However, it would not be completely reliable.

The best way to do this is to use a database.


An image can be POST-ed to a site just like any other file, and an HttpHandler can catch the incoming data and work with it.

The trick will just be gettimngthe in-memory representartion of the file posted to the handler.


I ended up having to just use AJAX and temporary files in order to get this done. There did not appear to be an easy way to transfer binary data directly to the handler.

0

精彩评论

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