如何从URL读取图片并在我的页面上显示 [英] How to read picture from URL and show it on my page
问题描述
我有一个sql表,其中包含信息:
I have a sql table which holds information:
id (hash)
imagename string
width int
height int
创建.net图像读取的最佳方法是什么在页面中显示图像。我想把它称为image.aspx / ashx?id = [id],函数将尝试捕获并显示该图像。
What is the best way to create .net image read which will show images in page. I would like to call it like image.aspx/ashx?id=[id] and function will try to catch and show that image.
我知道如何从SQL获取数据,但我不知道如何从URL读取img并将其显示为图像。
I know how to get data from SQL but I dont know how to read img from URL and show it as image.
有什么可以指点我的一些相关信息如何做或显示一段代码如何工作?
Could any please point me at some relevant information how to do it or show piece of code how it works?
我是否将其作为流阅读?
Do I read it as stream?
谢谢
推荐答案
string imageFileName = "thefile.jpg";
context.Request.MapPath(@"IMAGES\" + context.Request.QueryString["id"]);
context.Response.ContentType = "image/jpeg";
context.Response.WriteFile(imageFileName);
context.Response.Flush();
context.Response.Close();
http://msdn.microsoft.com/en -us / library / ms973917.aspx
这篇关于如何从URL读取图片并在我的页面上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!