Re: is_readable(http://.... text file) says not, but I canin browser
| From: | Nathan Rixham | Date: | Sun, 11 Jan 2009 18:21:36 +0000 |
| Subject: | Re: is_readable(http://.... text file) says not, but I canin browser | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286040@lists.php.net to get a copy of this message | ||
John Allsopp wrote:
Daniel Brown wrote:error supression is @ so: <?phpOn Sun, Dec 28, 2008 at 13:02, John Allsopp <john@johnallsopp.co.uk> wrote:Thanks, that worked a treat except I was getting warnings on 404. I looked around for solutions to that and it appears curl might handle that better, so I'm currently working on that. Many thanks tho .. let me know if you know how to stop the warnings :-) JSimplified: <?php$myFileLast = "http://www.myDomain.com/text.txt"; if (is_readable($myFileLast)) { $fh = fopen($myFileLast, 'r'); $theDataLast = fread($fh, 200); fclose($fh); echo ("The dataLast: ".$theDataLast."<br>\n"); } else { echo ("Last fix file unavailable: $myFileLast<br>\n"); }$myFileLast = "http://www.myDomain.com/text.txt"; $theDataLast = file_get_contents($myFileLast);?>You can manipulate the code as you see fit. If it doesn't work,then check your php.ini file (if you have access) to ensure that you have this line:allow_url_fopen = On
$myFileLast = "http://www.myDomain.com/text.txt"; $theDataLast = @file_get_contents($myFileLast);?> or using a conditional block <?php $myFileLast = "http://www.myDomain.com/text.txt"; if( ($theDataLast = file_get_contents($myFileLast)) !== FALSE ) {
// proceed} ?>