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

This is a discussion on Anyone know how to create automatic download using CURL and creating a new folder every day??? within the PHP Language forums, part of the PHP Programming Forums category; I want to save a zip file daily. The file is named the same thing each day so I would ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-07-2007
TechieGrl
 
Posts: n/a
Default Anyone know how to create automatic download using CURL and creating a new folder every day???

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!

Reply With Quote
  #2 (permalink)  
Old 08-07-2007
fabamb@gmail.com
 
Posts: n/a
Default Re: Anyone know how to create automatic download using CURL and creating a new folder every day???

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.com> wrote:
> 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!



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:42 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0