note 103977 deleted from function.fopen by danbrown
| From: | danbrown@php.net | Date: | Sun, 15 May 2011 16:05:36 +0000 |
| Subject: | note 103977 deleted from function.fopen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179736@lists.php.net to get a copy of this message | ||
Note Submitter: contact at lattery dot com
----
Use CURL to access files outside of your server (if you get Warning: fopen() [function.fopen]: URL
file-access is disabled in the server configuration):
Instead of using:
$file = "http://www.website.com/file.txt";
Use:
$file = "http://www.website.com/file.txt";
$ch = curl_init($file);
$fp = @fopen("temp.xml", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$file = "temp.xml";
//IMPORTANT: add an empty temp.xml file to your server and chmod to 666 so it can be written to.
If you don't know if you have CURL on your version of PHP, add:
<?php
phpinfo();
?>
to a PHP web page and look for the CURL section.
Or, you could simply try the code above and see if it works.