Search This Blog

2017/01/19

Read file by php which forbidden by .htaccess

Folder "file" is forbidden to access by .htaccess file as below:
 Options -Indexes 
 # Controls who can get stuff from this server. 
 Order Deny,Allow 
 Deny from all 
 #Allow from localhost

Try to get content from /file/1.html which is forbidden to access directly through php.
Code:
echo "Read 1.html file in folder 'file':";
$file_handle = fopen($_SERVER['DOCUMENT_ROOT'] . "/file/1.html", "r"); 
//$file_handle = fopen("http://www.randinblogger.blogspot.com/", "r");
while (!feof($file_handle)) {
 $line = fgets($file_handle);
 echo $line;
}
fclose($file_handle);

No comments :

Post a Comment