Use iframe to indicate files other than the htdocs folder

Source: Internet
Author: User
Use iframe to indicate a file other than the htdocs folder.

. If you place file.txt in d: \ txt \ file.txt, it cannot be found at http://mydomain.com/file.txt. Use http://mydomain.com/file.php to access File.txt, because file.php is accessible.


Reply to discussion (solution)

Files that are not managed by the web server cannot be accessed through http.
You need to transfer data through the php program

What should I do? My filelist page number can refer to any folder. Can I change it to an embedded file to open it? The page number is as follows:


Error_reporting (0 );
$ Basedir = "c:/filelist ";
If (! Is_dir ($ basedir) $ basedir = dirname (_ FILE __);
$ File_name = $ _ GET ['downfile'];
If (! Empty ($ file_name )){

$ File_dir = $ basedir. "/". $ file_name;

If (dirname (realpath ($ file_dir) <$ basedir ){

Echo "Permission Denied! ";

Exit;

}

If (! File_exists ($ file_dir )){

Echo "File Not Found! ";

Exit;

} Else {

$ File = fopen ($ file_dir, "r ");

Header ("Content-type: application/octet-stream ");

Header ("Accept-Ranges: bytes ");

Header ("Accept-Length:". filesize ($ file_dir ));

Header ("Content-Disposition: attachment; filename =". $ file_name );

Echo fread ($ file, filesize ($ file_dir ));

Fclose ($ file );

Exit;

}
}
Header ("Content-type: text/html; charset = utf-8 ");
$ RequestDir = $ _ GET ['dir'];
If (empty ($ requestDir )){

$ Dir = $ basedir;
} Else {

$ Dir = $ basedir. "/". $ requestDir;
}
$ Dir = realpath ($ dir );
If ($ dir <$ basedir) $ dir = $ basedir;
?>



File Listing














File Listing Sign Out




























































$ Dirs = @ opendir ($ dir ); $ Count = 0; While ($ file = @ readdir ($ dirs )){ $ B = "$ dir/$ file "; $ A = @ is_dir ($ B ); If ($ a = "1 "){ If ($ file! = "..." & $ File! = "."){ If ($ count <1 ){ $ Count ++; Echo" \ N "; Echo" \ N "; Echo" \ N "; } Echo" \ N "; Echo" \ N "; Echo" \ N "; } } } @ Closedir ($ dirs ); ?>

$ Predir = realpath ($ dir ."/../");

If ($ predir> $ basedir) $ predir = str_replace ($ basedir. "/", "", $ predir );

If ($ predir = $ basedir) $ predir = ".";

If ($ dir> $ basedir) echo "Up Level ";

?>

Folder
$ Basedir? Str_replace ($ basedir. "/", '', $ dir."/"):''). urlencode ($ file). "\"> $ file

























































$ Dirs = @ opendir ($ dir ); While ($ file = @ readdir ($ dirs )){ $ B = "$ dir/$ file "; $ A = @ is_dir ($ B ); If ($ a = "0 "){ $ Size = @ filesize ("$ dir/$ file "); $ Size = $ size/1024; $ Size = @ number_format ($ size, 2 ); $ Lastsave = @ date ("Y-n-d H: I: s", filemtime ("$ dir/$ file ")); Echo" \ N "; Echo" \ N "; Echo" \ N "; Echo" \ N "; Echo" \ N "; Echo" \ N "; } } @ Closedir ($ dirs ); ?>
Filename Date Size Action
$ File$ Lastsave$ Size KB$ Basedir? Str_replace ($ basedir. "/", '', $ dir."/"):''). urlencode ($ file). "\"> Download


Solved. use the following code.


$ File_handle = fopen ("outsidefile/file.txt", "r ");

While (! Feof ($ file_handle )){

$ Line_of_text = fgets ($ file_handle );
Print $ line_of_text ."
";

}

Fclose ($ file_handle );
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.