【发布时间】:2018-01-20 16:09:32
【问题描述】:
我正在本地主机上开发我的第一个 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)
【问题讨论】:
-
如果您的页面位于 myProjectRootFolder 下,那么您只需根据图像文件夹的位置调用 。这仅在图像文件夹位于 myProjectRootFolder 中时才有效
-
在 localhost 中提供子目录和图像位置的完整详细信息
标签: php html directory localhost root