<?php
// directory path can be either absolute or relative
$dirPath = "C:/xampp/htdocs/statistics/pdf/";
// open the specified directory and check if it's opened successfully
if ($handle = opendir($dirPath)) {
// keep reading the directory entries 'til the end
$i=0;
while (false !== ($file = readdir($handle))) {
$i++;
// just skip the reference to current and parent directory
if (eregi("\.pdf",$file)){
if (is_dir("$dirPath/$file")) {
// found a directory, do something with it?
echo "<a href='$dirPath/$file' ><font color='black' link='black' vlink='black' > $file </font></a><br>";
} else {
// found an ordinary file
echo "<a href='$dirPath/$file' ><font color='black' link='black' vlink='black' >$i . $file </font></a><br>";
}
}
}
// ALWAYS remember to close what you opened
closedir($handle);
}
?>
<iframe src="xxx" width="100%" height="800"style="border: none;"></iframe>
我想从我的dir打开iframe div中的每个不同文件,隐藏前一个并显示按下的链接。我从路径打开它的那些文件,我希望有一个包含这些文件的列表,并在iframe中打开它。
答案 0 :(得分:0)
您想要定位iFrame?
if (is_dir("$dirPath/$file")) {
// found a directory, do something with it?
echo "<a href='$dirPath/$file' target='iframe1'><font color='black' link='black' vlink='black' > $file </font></a><br>";
} else {
// found an ordinary file
echo "<a href='$dirPath/$file' target='iframe2'><font color='black' link='black' vlink='black' >$i . $file </font></a><br>";
}
使用
<iframe name="iframe1" src="about:blank" width="100%" height="800"style="border: none;"></iframe>
<iframe name="iframe2" src="about:blank" width="100%" height="800"style="border: none;"></iframe>