我从数据库中以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中的临时文件夹,则不显示图像
发布评论