Re: is_readable(http://.... text file) says not, but I can in browser
| From: | Nathan Nobbe | Date: | Sun, 28 Dec 2008 23:05:20 +0000 |
| Subject: | Re: is_readable(http://.... text file) says not, but I can in browser | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-285167@lists.php.net to get a copy of this message | ||
On Sun, Dec 28, 2008 at 11:02 AM, John Allsopp <john@johnallsopp.co.uk>wrote:
> Hi
>
> I'm sure this is simple for yous all but I'm not sure I know the answer.
>
> $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");
> }
>
> returns Last fix file unavailable even for a file that my browser can read.
> All I want to do is skip over files
>
> This could be a very simple error, I'd appreciate a pointer. Is it
> permissions being different for PHP versus the browser or something? PHP is
> running on a different server.
are you basically trying to tell if theres a resource @ the given url? if
so, id prefer curl myself.
something like
if(($ch = curl_init($url) === false)
echo ("Last fix file unavailable: $myFileLast<br>\n");
else {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);*
* $theDataLast = curl_exec($ch);
echo ("The dataLast: ".$theDataLast."<br>\n");*
* curl_close($ch);*
*}
obviously, youll need the curl extension installed for this to work. i know
the fopen wrappers will allow you to get a read-only handle to an http url,
but im not sure what is_readable() will do w/ that, it may be limited to the
local filesystem.
-nathan