如果Url来自Asp.net中的临时文件夹,则不显示图像

编程入门 行业动态 更新时间:2024-10-12 05:46:03
本文介绍了如果Url来自Asp中的临时文件夹,则不显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我从数据库中以byteArray格式获取Image的内容,并在Asp中显示内容图像标记。这里的问题是当我将图像文件保存在我的工作文件夹中的特定位置并显示图像正常工作时。 但是如果我试图暂时保存图像文件夹并将临时文件夹url提供给图像标记它没有显示图像。代码是:

I am taking the content of Image in byteArray format from database and displaying the Content image tag in Asp. Here the problem is when i save the image file in Specific location in my working folder and displaying the image working fine. But if i trying to save the image in temporary folder and giving the temporary folder url to image tag it doesn''t displaying the image. The code is:

Bitmap bi = new Bitmap(byteArrayToImage(FileUpload1.FileBytes)); //This code working fine string path = Server.MapPath("Images/") + FileUpload1.PostedFile.FileName; bi.Save(path , ImageFormat.Jpeg); Image1.ImageUrl = "Images/" + FileUpload1.PostedFile.FileName; //This code didn't displaying the image. bi.Save(Path.GetTempPath() + FileUpload1.PostedFile.FileName, ImageFormat.Jpeg); Image1.ImageUrl = Path.GetTempPath() + FileUpload1.PostedFile.FileName;

这里的tempFolder有什么问题。我正在使用Windows7操作系统。在这里我使用temparory文件夹自动删除文件夹中创建的图像。 请在这里给出有用的技巧。 谢谢

what is the problem with the tempFolder here.I am using the Windows7 operating system. Here i am using the temparory folder for automatically deleting the created images in folder. Please give to useful technique here. Thank you

推荐答案

糟糕的设计。 将您的应用程序想象为在Web服务器上运行(实际上,开发服务器是一个简单的Web服务器)。 Web服务器是否会从它的OS临时文件夹中提供服务?从不。 您只能使用Web服务器服务范围内的图像源。请注意,浏览需要逻辑服务路径,而不是物理路径 - 因为它无法访问服务器物理文件系统。 Bad design. Think of your application as running on a web server (actually the development server is a simple web server). Will the web server serve from it''s OS temporary folder? Never. You can only use image sources that are in the served scope of your web server. And be aware, that the browses needs logical served paths, not physical ones - since it can not access server physical file system.

更多推荐

如果Url来自Asp.net中的临时文件夹,则不显示图像

本文发布于:2023-11-07 07:24:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565873.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   临时文件夹   Url   Asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!