我正在开发我在localhost上的第一个PHP webapp。我无法引用子目录中的文件。例如,从我项目的任何页面,如果我必须调用以下页面,图像就不会出现。
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Page is Under Construction</title>
</head>
<body>
<style>
.imgcontainer {
text-align: center;
margin: 10px 0 5px 0;
position: center;
}
</style>
<div class="imgcontainer" style="padding:0px;">
<img src="/myProjectRootFolder/images/under-construction.png" alt=""/>
</div>
</body>
</html>
控制台上的错误消息是
UnderConstruction.php:25 GET http://localhost/myProjectRootFolder/images/under-construction.png 404 (Not Found)
答案 0 :(得分:2)
可能是你需要一个相对路径
<img src="./myProjectRootFolder/images/under-construction.png" alt=""/>
或
<img src="./images/under-construction.png" alt=""/>
并确保您的真实形象和路径名..
如果你调用页面的网址是
/myProjectRootFolder/summary/salessummary.php
你应该使用相对路径
<img src="../images/under-construction.png" alt=""/>
然后你应该使用