Re: is_readable(http://.... text file) says not, but I canin browser
| From: | Nathan Rixham | Date: | Sun, 11 Jan 2009 18:18:54 +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-286039@lists.php.net to get a copy of this message | ||
John Allsopp wrote:
Nathan Nobbe wrote:might be a bracket thing.. could try: if( ($ch = curl_init($url)) === false) { echo ("Last fix file unavailable: $myFileLast<br>\n"); } else { .... or if( !is_resource($ch = curl_init($url)) ) { echo ("Last fix file unavailable: $myFileLast<br>\n"); } else { ....On Sun, Dec 28, 2008 at 11:02 AM, John Allsopp <john@johnallsopp.co.uk>wrote:Thanks. I'm trying to read the contents of the file at the URL, but it might not exist. So far I'm getting a lot of *Warning*: curl_setopt(): supplied argument is not a valid cURL handle resource in */home/myAcc/public_html/test.php* on line *58 * I searched phpinfo for 'curl' and it came up nothing, so I'm just checking with my hosts to see if I have the extension installed. I'll be back, thanks JHi I'm sure this is simple for yous all but I'm not sure I know the answer.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$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.