Reading a text file from another server, Reading a simple text file from another website |
Reading a text file from another server, Reading a simple text file from another website |
TheHeist |
Jan 10 2011, 11:37 AM
Post
#1
|
Member Group: Members Posts: 32 Joined: 1-September 10 Member No.: 12,636 |
Hi, I am trying to make it so that when anyone uses my code it automatically loads news from a file on my site. I can do it locally but can't get it to load using url. Any suggestions? And can I name the file: news.data instead of news.txt or will that screw it up?
Thanks, The Heist This doesn't work: CODE $myFile = "http://www.enochwright.com/news.txt"; $fh = fopen($myFile, 'r'); $theNews = fread($fh, filesize($myFile)); fclose($fh); |
Darin McGrew |
Jan 10 2011, 11:55 AM
Post
#2
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
What output or log messages do you get? I'm not really familiar with PHP, but according to the fopen docs, "If no wrappers for that protocol are registered, PHP will emit a notice to help you track potential problems in your script and then continue as though filename specifies a regular file."
|
TheHeist |
Jan 10 2011, 12:20 PM
Post
#3
|
Member Group: Members Posts: 32 Joined: 1-September 10 Member No.: 12,636 |
CODE Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /homepages/43/d318702296/htdocs/ew/cms/index.php on line 7 Warning: fopen(http://www.enochwright.com/cms/news.txt) [function.fopen]: failed to open stream: no suitable wrapper could be found in /homepages/43/d318702296/htdocs/ew/cms/index.php on line 7 Warning: filesize() [function.filesize]: stat failed for http://www.enochwright.com/cms/news.txt in /homepages/43/d318702296/htdocs/ew/cms/index.php on line 8 Warning: fread(): supplied argument is not a valid stream resource in /homepages/43/d318702296/htdocs/ew/cms/index.php on line 8 Warning: fclose(): supplied argument is not a valid stream resource in /homepages/43/d318702296/htdocs/ew/cms/index.php on line 9 |
Christian J |
Jan 10 2011, 01:37 PM
Post
#4
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
CODE Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration The above seems to explain it. http://www.php.net/manual/en/function.fopen.php also says QUOTE If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail. Finally, http://www.php.net/manual/en/filesystem.co...allow-url-fopen explains how to change this. |
TheHeist |
Jan 10 2011, 01:44 PM
Post
#5
|
Member Group: Members Posts: 32 Joined: 1-September 10 Member No.: 12,636 |
Thanks, I'll take a look tonight after classes!
-The Heist |
Christian J |
Jan 10 2011, 04:22 PM
Post
#6
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Seems it's a php.ini setting, and as such the web host may not want to change it...
|
TheHeist |
Jan 10 2011, 08:15 PM
Post
#7
|
Member Group: Members Posts: 32 Joined: 1-September 10 Member No.: 12,636 |
Yea, just read it. Looks like that option is out the window. Any ideas on loading a file from another website?
|
Brian Chandler |
Jan 10 2011, 09:32 PM
Post
#8
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
Yea, just read it. Looks like that option is out the window. Any ideas on loading a file from another website? Try the curl library (curl in the php manual)... It's a bit more fiddly, but the problem with the url-open option is that it allows exploits in various badly written software. |
Lo-Fi Version | Time is now: 23rd April 2024 - 04:00 PM |