473,385 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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!

Aug 7 '07 #1
1 2920
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Skip Montanaro | last post by:
I wrote PEP 304, "Controlling Generation of Bytecode Files": http://www.python.org/peps/pep-0304.html quite awhile ago. The first version appeared in January 2003 in response to questions...
2
by: Creat ASP Page Automatic | last post by:
Hi; I want to ask you something very important for me .. how can i Create daynamic pages or static pages Automatic .??????????!!! i have a problem with my website i want Create page asp...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
6
by: JonSteng | last post by:
..Net Visual Studio Professional 2003 Version 7.1.3088 ..Net Framework 1.1 SP1 Version 1.1.4322 IIS 5.1 Windows XP Professional SP2 Micron T3000 Laptop (1.5 GHz; 1GB RAM; 40GB HD with 17GB Free)...
45
by: salad | last post by:
I'm curious about your opinion on setting relationships. When I designed my first app in Access I'd go to Tools/Relationships and set the relationships. Over time I'd go into the window and see...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
1
by: Rajen | last post by:
I've a automatic configuration proxy (http://xxx.xxx.xxx.xxx/xyz.pac) which I use in the Internet explorer Lan Settings to access the net. How do I read a webpage by specifying this proxy in my...
4
by: shikakaa | last post by:
Hi! I have a server I'd like to download hundreds of pages from, and only get the first few kilobytes of every page to save resources on both my and the remote end. Since the serfver doesn't...
5
by: DustinP | last post by:
I have installed PHP5 as ISAPI several times per every single guide I could find in the first 50 pages of results on google.. Server is Windows 2008 runing IIS7, phpinfo works and tells me the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.