日期:2014-05-17  浏览次数:20434 次

关于图片上传预览的问题
我在html页文件上传到ashx页面,然后在ashx页面显示图片
HttpPostedFile file = context.Request.Files["file"];
            if (file != null)
            {
                context.Response.ContentType = "text/image";
                using (Image img = Image.FromStream(file.InputStream))
                {
                    img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
             }

图片也能显示出来,但是我想在html页面嵌一个iframe,src设置为ashx,想在这个页面显示图片。
form里target设置为这个iframe,页面没有跳转,调试代码也一步步执行了,但是最后就是不显示图片,如果在ashx页输出文字倒是可以显示。
估计是页面显示图片方式不对吧,不知道应该怎么写。
------解决方案--------------------