获取文件列表,点击文件名打开文件的方法,哪位有时间帮帮忙啊

WBOY
Release: 2016-06-23 14:10:21
Original
1155 people have browsed it

左右两栏,左栏提取某目录下的所有HTML文件,鼠标点击文件名,可以在右栏显示点击的HTML文件这是HTML结构		<div id="sidebar">			<p>文件目录如下:</p>			<div id="fileList">				<?php					getFile("要索引的目录路径");				?>			</div>		</div>		<div id="main">			//此处显示点击的HTML文件            //echo openFile(就这里不会写);		</div>	//获取文件列表函数	function getFile($dir) {	    $fileArray[]=NULL;	    if (false != ($handle = opendir ( $dir ))) {	        $i=0;	        while ( false !== ($file = readdir ( $handle )) ) {	            //去掉"“.”、“..”以及带“.xxx”后缀的文件	            if ($file != "." && $file != ".."&&strpos($file,".")) {	                $fileArray[$i]="".$file;	                if($i==100){	                    break;	                }	                $i++;	            }	        }	        //关闭句柄	        closedir ( $handle );	    }		foreach($fileArray as $value)		{			echo "<a href='".$value."'>".$value."</a>"; //这里输出数组内容			echo "<br/>";		}	    return $fileArray;	}		//打开文件函数	function openFile($filename) 	{    		$return = '';    		if ($fp = fopen($filename, 'rb')) 		{      			while (!feof($fp))			{       				$return .= fread($fp, 1024);     			}      			fclose($fp);      			return $return;   		 } 		else 		{  			return false;    		}  	} [code=php]
Copy after login
[/code]


回复讨论(解决方案)

用框架来布局,在a标签中指定target属性即可。可以参考csdn论坛的写法。

php中怎么实现类似资源管理器左侧树形结构?

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template