我正在使用html来创建页面。但我面临的问题是我没有打算成像。我的代码是:
<html>
<head runat="server">
<title>Untitled Page</title>
</head>
<body style = " background:#FFA500">
<form id="form1" runat="server">
<div>
<h1>
header_picture
</h1>
<img src="C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Water lilies.jpg" />
</div>
<div>
<h1>
here comes the content
</h1>
</div>
<div>
<h2>
footer_picture
</h2>
<img src="C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Blue hills.jpg" />
</div>
</form>
</body>
</html>
但是当我在浏览器中运行这个html文件时,它没有显示我的图像.. 请帮帮我..
is this possible to give image url on run time in <img src> tag in html file.. if yes how can we do that..
答案 0 :(得分:3)
出于安全原因,在许多现代浏览器中不再可以从非file://
位置引用本地文件(即使它是localhost
)。
Not allowed to load local resource: file:///C:/path/to/filename
您必须将HTML文件放入本地文件夹(可能不是您想要的,因为其中包含服务器端代码)或将图像移动到您可以通过Web服务器调用的位置。
答案 1 :(得分:3)
您应该将C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Water lilies.jpg
更改为file:///C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Water lilies.jpg
,并将其与您的其他网址相同。