Javascript 尝试使用模式预览图像时出现问题
我试图让它成为当客户端/用户点击他们的图像时,会弹出他们点击的图像。我尝试过使用一个模型,但当你点击图片时,它不会显示你点击的图片,而是会显示所有照片的不同图片?你知道我的代码为什么这么做吗?先谢谢你 下面的代码显示用户文件夹中的图像。Javascript 尝试使用模式预览图像时出现问题,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我试图让它成为当客户端/用户点击他们的图像时,会弹出他们点击的图像。我尝试过使用一个模型,但当你点击图片时,它不会显示你点击的图片,而是会显示所有照片的不同图片?你知道我的代码为什么这么做吗?先谢谢你 下面的代码显示用户文件夹中的图像。 foreach($images作为$image){ 回声' 这是我所有的代码。 $username = $_SESSION['user']['username']; $dirname = "photos/$username/"; // Only Get
foreach($images作为$image){
回声'
这是我所有的代码。
$username = $_SESSION['user']['username'];
$dirname = "photos/$username/";
// Only Get .png Images // $images = glob($dirname."*.png");
$images = glob("$dirname*.{jpg,gif,png}", GLOB_BRACE);
foreach($images as $image) {
echo '
<div id="gallery">
<div id="gallery-content">
<div id="gallery-content-center">
<a href="#" data-toggle="modal" data-target="#myModal" data-gallery="multiimages" ><img src="'.$image.'" alt="gallery" class="all studio" /> </a>
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Preivew of your Image</h4>
</div>
<div class="modal-body">
<img src="'.$image.'" /> </a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default waves-effect" data-dismiss="modal">Close</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
';
}
?>
$username=$\u会话['user']['username'];
$dirname=“photos/$username/”;
//仅获取.png图像//$Images=glob($dirname.*.png”);
$images=glob($dirname*{jpg,gif,png}),glob_括号);
foreach($images作为$image){
回声'
×
注意你的形象
接近
';
}
?>
这就是它对您单击的所有图像所做的。
所有模式对话框都有相同的
id
-myModal
因此,当您显示模态对话框时,第一个模态始终处于选中状态
简单的方法是使用各种id
例如:
$username = $_SESSION['user']['username'];
$dirname = "photos/$username/";
// Only Get .png Images // $images = glob($dirname."*.png");
$images = glob("$dirname*.{jpg,gif,png}", GLOB_BRACE);
$image_index = 0;
foreach($images as $image) {
$image_index++;
echo '
<div id="gallery">
<div id="gallery-content">
<div id="gallery-content-center">
<a href="#" data-toggle="modal" data-target="#myModal'.$image_index.'" data-gallery="multiimages" ><img src="'.$image.'" alt="gallery" class="all studio" /> </a>
<div id="myModal'.$image_index.'" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Preivew of your Image</h4>
</div>
<div class="modal-body">
<img src="'.$image.'" /> </a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default waves-effect" data-dismiss="modal">Close</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
';
}
?>
$username=$\u会话['user']['username'];
$dirname=“photos/$username/”;
//仅获取.png图像//$Images=glob($dirname.*.png”);
$images=glob($dirname*{jpg,gif,png}),glob_括号);
$image_index=0;
foreach($images作为$image){
$image_index++;
回声'
×
注意你的形象
接近
';
}
?>
所有模式对话框都有相同的id
-myModal
因此,当您显示模态对话框时,第一个模态始终处于选中状态
简单的方法是使用各种id
例如:
$username = $_SESSION['user']['username'];
$dirname = "photos/$username/";
// Only Get .png Images // $images = glob($dirname."*.png");
$images = glob("$dirname*.{jpg,gif,png}", GLOB_BRACE);
$image_index = 0;
foreach($images as $image) {
$image_index++;
echo '
<div id="gallery">
<div id="gallery-content">
<div id="gallery-content-center">
<a href="#" data-toggle="modal" data-target="#myModal'.$image_index.'" data-gallery="multiimages" ><img src="'.$image.'" alt="gallery" class="all studio" /> </a>
<div id="myModal'.$image_index.'" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Preivew of your Image</h4>
</div>
<div class="modal-body">
<img src="'.$image.'" /> </a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default waves-effect" data-dismiss="modal">Close</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
';
}
?>
$username=$\u会话['user']['username'];
$dirname=“photos/$username/”;
//仅获取.png图像//$Images=glob($dirname.*.png”);
$images=glob($dirname*{jpg,gif,png}),glob_括号);
$image_index=0;
foreach($images作为$image){
$image_index++;
回声'
×
注意你的形象
接近
';
}
?>
啊!谢谢!现在可以用了!:)这是我的荣幸。啊!谢谢!现在可以用了!:)这是我的荣幸。