如何通过asp.net 2.0在图像框中显示图像 [英] How to display image in in image box through asp.net 2.0

查看:66
本文介绍了如何通过asp.net 2.0在图像框中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过asp.net 2.0在图像框中显示图像
我已经为此编写了代码...并且使用了fileuploadImage控件.

How to display image in in image box through asp.net 2.0
i have written code for it...and i use fileuploadImage control.

if (fileuploadImage.HasFile)
            {
          
            int length = fileuploadImage.PostedFile.ContentLength;
           
            byte[] imgbyte = new byte[length];
           
            HttpPostedFile img = fileuploadImage.PostedFile;
          
            img.InputStream.Read(imgbyte, 0, length);
          
            Image1.ImageUrl = Server.MapPath(fileuploadImage.FileName);



但图像不显示.请帮我...



but the image not displaying. please help me...
thanks.

推荐答案

您需要将上传的图像保存到文件中,然后将ImageUrl设置为将图像保存到的路径.
You will need to save the uploaded image to a file and then set the ImageUrl to the path that you save the image to.


<br />
<pre lang="cs">if (fileuploadImage.HasFile)<br />
{<br />
     fileuploadImage.SaveAs(Server.MapPath("~/") + fileuploadImage.FileName);<br />
<br />
     Image1.ImageUrl = "~/" + fileuploadImage.FileName;<br />
}</pre><br />


请查看此代码项目Q/A.
Please take a look at this Code Project Q/A.To display binary formatted image from database[^]


这篇关于如何通过asp.net 2.0在图像框中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆