Jump to content

[SOLVED] Forbiddent to view .txt


newbtophp

Recommended Posts

I was wondering is their a way i can make the  text.txt file execute when using fopen, but when i visit the file directorally it will display a forbidden message?

 

I've tried chmodding, the forbidden message displays but fopen wont work

 

This is my code:

 

//I want the url to be forbidden, so vistors can't access directaly
$url="http://domain.com/text.txt";
//But the trouble is if i chmod the above file the below code wont work
$fp = fopen($url, "r");

 

All help is apreciated  :D

Link to comment
https://forums.phpfreaks.com/topic/170182-solved-forbiddent-to-view-txt/
Share on other sites

Tested, it makes the folder and protected files forbidden but fopen wont work.

 

Warning: fopen(http://domain.com/text.txt) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home/me/public_html/test.php on line 9

 

Any other way?

Use a file system path to open the file with. When you use a URL, you are causing your web server/php to make a http request back to itself, just like a browser would, to read the file. Using a URL also takes about 100 times longer to read the file than if you were reading it through the file system.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.