By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

Anyone know how to create automatic download using CURL and creating a new folder every day???

P: n/a
I want to save a zip file daily. The file is named the same thing
each day so I would like to create a folder and name it with today's
date and then save the zip file into that folder.

I'm using this code and can't seem to figure out how to create the new
folder and save the file there.
Any help is appreciated!

$todays_date = date("Ymd");

$fp = fopen (dirname(__FILE__) . '/file.zip', 'w+');//This is the file
where we save the information
$ch = curl_init('http://www.downloadhere.com/file.zip');//Here is the
file we are downloading
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);

So each day I should have something like 20070807\file.zip.

Any help on how to do this would be greatly appreciated.
THANKS!

Aug 7 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You have to create the directory before downloading and change
filename constuction:
$dirname = dirname(__FILE__) . '/' . date("Ymd");
mkdir($dirname);
$filename = $dirname . '/file.zip';
$fp = fopen($filename, 'w+);
....

You must have permsissions to create directories and files under
dirname(__FILE__) directory, of course;
On 7 Ago, 22:26, TechieGrl <cschal...@gmail.comwrote:
I want to save a zip file daily. The file is named the same thing
each day so I would like to create a folder and name it with today's
date and then save the zip file into that folder.

I'm using this code and can't seem to figure out how to create the new
folder and save the file there.
Any help is appreciated!

$todays_date = date("Ymd");

$fp = fopen (dirname(__FILE__) . '/file.zip', 'w+');//This is the file
where we save the information
$ch = curl_init('http://www.downloadhere.com/file.zip');//Hereis the
file we are downloading
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);

So each day I should have something like 20070807\file.zip.

Any help on how to do this would be greatly appreciated.

THANKS!

Aug 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.