CodeIgniter Forums
curl and php file downloading - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter Archived (from EllisLab) (
+--- Forum: Archived Development & Programming (
+--- Thread: curl and php file downloading (/thread-49843.html)

curl and php file downloading - El Forum - 03-05-2012

Hi, I've got one problem.
I want to download remote image using curl. To do this i'm using these isntructions:

This is usefull when you are downloading big files, as it
will prevent time out of the script :
ini_set('display_errors',true);//Just in case we get some errors, let us know....

$fp = fopen (dirname(__FILE__) . '/a.rss', 'w+');//This is the file where we save the information
$ch = curl_init('');//Here is the file we are downloading
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

but it says that there is no such file or directory in (and this is weird) home/username/localhost/..
it gives the full system array to my localhost folder. Why?

When I'm doing this by:
It normally creates an image file in my main localhost folder, but i prefer to use curl. What's wrong?

Edit: ofc i know, that variable dirname(__FILE__) contains my full system path - but why? How can I do it same as in PHP without entering the full system path?