我在文件夹docs中创建图像并在动态创建的img标签中显示该图像,但图像不显示为什么? [英] I am creating image in folder docs and showing that image in dynamically created img tag but images are not displayed why ?

查看:131
本文介绍了我在文件夹docs中创建图像并在动态创建的img标签中显示该图像,但图像不显示为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string fileID = Guid.NewGuid().ToString();
Byte[] imgBytes = p.ImgContent;
string filePath = Server.MapPath("~/Docs/" + fileID + p.ImgName);
FileStream fs = File.Create(filePath);
fs.Write(imgBytes, 0, imgBytes.Length);
fs.Flush();
fs.Close();

liContent.Text += "<a class='flipLightBox' href='" + filePath + "'>" + "<img class ='content' src=\"" + filePath + "\" />" + "&nbsp;" + "<span><b>" + p.Title + "</b>" + "<br>" + p.Description + "</span>" + "</a>";









为<$ c添加了正确的语言$ c> pre 标签。

[/编辑]

推荐答案

图像未显示的原因是因为您使用文件系统链接到它们。意思是,路径就像是,C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\一个网址,因为客户端的浏览器实际上会请求它并需要访问它。
The reason the images do not show is because you are linking to them using the file system. Meaning, the path is something like, "C:\intepub\wwwroot\yourapp\docs\filename.jpg"

The path needs to be a url because it is the client's browser that will actually request it and needs access to it.


这篇关于我在文件夹docs中创建图像并在动态创建的img标签中显示该图像,但图像不显示为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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