这是循环:
<?php
// I added this just to see if HTML_PATH_UPLOADS_PAGES points to the right directory
echo "<img style=\"width:100%;height:100%;\" src=\"" . HTML_PATH_UPLOADS_PAGES . "c60fca4c682803c969f2410084878155/1.jpg\">\n";
// Loop through all the image files in the right sidebar.
foreach (glob(HTML_PATH_UPLOADS_PAGES . "c60fca4c682803c969f2410084878155/{*.[gG][iI][fF],*.[jJ][pP][gG],*.[jJ][pP][eE][gG],*.[pP][nN][gG]}", GLOB_BRACE) as $image) {
// Display the image in the right sidebar.
echo "<div class=\"col-md-6 col-lg-4 item zoom-on-hover\">\n";
echo "<a class=\"lightbox\" href=\"" . HTML_PATH_UPLOADS_PAGES . "c60fca4c682803c969f2410084878155/" . basename($image) . "\">\n";
echo "<img class=\"img-fluid image\" src=\"" . HTML_PATH_UPLOADS_PAGES . "c60fca4c682803c969f2410084878155/" . basename($image) . "\" >\n";
echo "</a>\n";
echo "</div>\n";
}
?>
这是放置循环的pictures.php文件的位置:
这是图像所在的目录:
编辑:
这是HTML_PATH_UPLOADS_PAGES
中定义的/bludit/bl-kernel/boot/init.php
的定义:
$base = '';
if (!empty($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['SCRIPT_NAME']) && empty($base)) {
$base = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_NAME']);
$base = dirname($base);
} elseif (empty($base)) {
$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$base = dirname($base);
}
if (strpos($_SERVER['REQUEST_URI'], $base)!==0) {
$base = '/';
} elseif ($base!=DS) {
$base = trim($base, '/');
$base = '/'.$base.'/';
} else {
// Workaround for Windows Web Servers
$base = '/';
}
define('HTML_PATH_ROOT', $base);
define('HTML_PATH_UPLOADS_PAGES', HTML_PATH_ROOT.'bl-content/uploads/pages/');
答案 0 :(得分:0)
尝试添加此常量以获取文件夹的文件系统路径:
html {
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
* {
margin: 0px;
padding: 0px;
}
#main {
max-width: 1000px;
margin: 0 auto;
}
#menu:after {
content: "";
clear: both;
display: block;
}
#menu {
background-color: #000;
}
#menu ul {
list-style: none;
position: relative;
float: left;
margin: 0;
padding: 0
}
#menu ul a {
display: block;
color: #231F20;
font-size: 12px;
}
#menu ul li {
float: left;
margin: 0;
padding: 0
}
#menu ul li.current {
background: #ddd
}
#menu ul ul {
position: absolute;
top: 100%;
left: 0;
background: #ffffff;
border: 1px solid #4598cc;
padding: 20px 0px;
z-index: 5;
display:block;
visibility:hidden;
}
#menu ul ul li {
float: none;
width: 200px;
padding: 5px 10px;
}
#menu ul ul a {
color: #4598cc;
display: block;
padding: 5px 0;
font-style: 14px;
font-family: FFMarkStdBook;
}
#menu ul ul ul {
top: -1px;
left: 100%;
height: auto;
}
#menu ul li:hover>ul {
visibility:visible;
}
#menu>ul>li {
float: left;
margin-right: 47px;
position: relative;
}
#menu>ul>li:last-child {
margin-right: 0px;
}
#menu>ul>li>a {
color: #fff;
text-transform: uppercase;
font-size: 14px;
padding: 10px;
text-decoration: none;
}
#menu>ul>li>ul b {
color: #4598cc;
font-size: 14px;
text-transform: uppercase;
font-weight: normal;
}
然后将其与glob一起使用:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="main">
<nav id="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Services</a>
<ul>
<li><a href="#">Link One ></a>
<ul>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
</ul>
</li>
<li><a href="#">Link One ></a>
<ul>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
</ul>
</li>
<li><a href="#">Link One ></a>
<ul>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Projects</a>
<ul>
<li><a href="#"> Link One</a>
<ul>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
<li><a href="#">Child Link One</a></li>
</ul>
</li>
<li><a href="#"> Link One</a></li>
<li><a href="#"> Link One</a></li>
</ul>
</li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
具有相对路径的替代项:
define('FILE_PATH_UPLOADS_PAGES',
rtrim($_SERVER['DOCUMENT_ROOT'], '/\\') . '/bludit/bl-content/uploads/pages/');
但是,如果您真的根本不想创建另一个常量,则可以尝试:
glob(FILE_PATH_UPLOADS_PAGES . 'c60fca4c682803c969f2410084878155 ...');