在asp.net c#中从image对象将图像保存到服务器 [英] Save image to server from image object in asp.net c#
本文介绍了在asp.net c#中从image对象将图像保存到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图像对象,如何将其保存到服务器上的文件夹中(使用ap.net c#)。
字节 [] imageBytes =(字节 [])ds.Tables [ Images]。行[ 0 ] [ 0 跨度>];
Image1.ImageUrl = data:image / png; base64, + Convert.ToBase64String (imageBytes);
i搜索形式Image1.save(url);
或将此图像对象分配给fileupload控件的任何方法。 filemload.save();
解决方案
你不明白:Image
是一个抽象类: http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx?cs-save-lang=1&cs-lang = csharp#code-snippet-1 [ ^ ]。
运行时类型永远不会System.Drawing.Image
但是派生类之一;最有可能的是,它是System.Drawing.Bitmap
:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx [ ^ ]。
你需要自己找出你有什么类型的图像。具体类有保存
方法,请参阅文档。
-SA
I have an image object , how can i save it to an folder on server (using ap.net c#).
Byte[] imageBytes = (Byte[])ds.Tables["Images"].Rows[0][0];
Image1.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(imageBytes);
i searching form something Image1.save(url);
or any way to assign this image object to fileupload control. so that i can sav eit from there, fileupload.save();
解决方案
You don''t understand:Image
is an abstract class: http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1[^].
The run-time type of your image is neverSystem.Drawing.Image
but is one of derived classes; most likely, it isSystem.Drawing.Bitmap
:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[^].
You need to find it out by yourself what type of the image do you have. And concrete classes do haveSave
methods, please see the documentation.
—SA
这篇关于在asp.net c#中从image对象将图像保存到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文