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
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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.