我正在上传多个图片,并希望使用会话在另一个页面中显示所有这些图像。我怎样才能做到这一点?
第一页
$var_holding_img = "<img src='$File_Name' alt='picture' width='200' height='256'><br/>";
$string = $var_holding_img ;
$_SESSION['File_Name'] = $string; //storing multiple images
echo $_SESSION['File_Name'] ;
第二页
$File_Name=$_Session['File_Name']; //want to show all images
<?php echo $File_Name ?></div>
答案 0 :(得分:0)
第一页
<?php
$var_holding_img = "<img src='$File_Name' alt='picture' width='200' height='256'><br/>";
$_SESSION['File_Name'][] = $var_holding_img; //storing multiple images
?>
第二页
<div>
<?php
if (isset($_SESSION))
{
foreach ($_SESSION['File_Name'] as $key=>$File_Name)
{
echo $File_Name;
}
}
?>
</div>
示例:强>
<?php
if (isset($_SESSION['FileArray']))
unset($_SESSION['FileArray']);
$_SESSION['FileArray'][] = "<img src='http://php.net/images/logo.php' alt='picture' width='200' height='256'><br/>";
$_SESSION['FileArray'][] = "<img src='https://jquery.com/jquery-wp-content/themes/jquery/images/logo-jquery.png' alt='picture' width='200' height='256'><br/>";
if (isset($_SESSION))
{
foreach ($_SESSION['FileArray'] as $key=>$File_Name)
{
echo $File_Name;
}
}
?>