Obtain the file list and click the file name to open the file. Which of the following has time to help? in the left column, extract all HTML files in a directory and click the file name, the HTML file you click on is displayed in the right column. this is the HTML structure & lt; div & nbsp; & gt; & lt; p & gt; the file directory is as follows: & lt; p & gt; & lt; div & nbsp; & get the file list and click the file name to open the file. Which of the following time can someone help me?
In the left and right columns, all HTML files in a directory are extracted from the left column. click the file name to display the clicked HTML files in the right column.
This is an HTML structure
The file directory is as follows:
GetFile ("directory path to be indexed ");
?>
// The clicked HTML file is displayed here.
// Echo openFile (won't be written here );
// Obtain the object list function
Function getFile ($ dir ){
$ FileArray [] = NULL;
If (false! = ($ Handle = opendir ($ dir ))){
$ I = 0;
While (false! ==( $ File = readdir ($ handle ))){
// Remove "". "," .. ", and files with the suffix". xxx"
If ($ file! = "." & $ File! = ".." & Strpos ($ file ,".")){
$ FileArray [$ I] = "". $ file;
If ($ I == 100 ){
Break;
}
$ I ++;
}
}
// Close the handle
Closedir ($ handle );
}
Foreach ($ fileArray as $ value)
{
Echo "". $ value. ""; // The array content is output here.
Echo"
";
}
Return $ fileArray;
}
// Open the file function
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]
[/Code]
Share:
The file directory is as follows... 'data-pics = ''>
------ Solution --------------------
Use the frame for layout. specify the target attribute in TAG. Refer to the csdn Forum.