473,698 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.downloadher e.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.z ip.

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

Aug 7 '07 #1
1 2936
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...@gmai l.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.downloadher e.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.z ip.

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
1857
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 from people about controlling/suppressing bytecode generation in certain situations. It sat idle for a long while, though from time-to-time people would ask about the functionality and I'd respond or update the PEP. In response to another recent...
2
2005
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 classic to every member The page name equal the member name www.Micrsoft.com/Ashraf.asp
6
13721
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 error (seems to be happening when I try creating a directory) If dirmgr.Exists("s:\blah\" & txt_name.Text) Then lblerror.Text = lblerror.Text & "Unable to build physical path. " &
6
3366
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) I installed FrontPage server extensions to IIS on my computer while following instructions in a Microsoft ASP.Net MCSD training book. After installing the FrontPage Server Extensions I cannot create a new
45
3397
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 relationship spaghetti....tables/queries all overthe place with lots of relationship lines between here and there. After that first app I didn't do relationships. If I had a query, I defined the relationship. Many of the times when I create a...
3
18708
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, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
1
2646
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 PHP code. By the by, I'm using curl to read the remote webpage. I've tried the option curl_setopt($ch, CURLOPT_PROXY, 'http://xxx.xxx.xxx.xx/xyz.pac'); but didn't work.
4
2832
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 support HTTP range to use it in curl like curl_setopt($ch, CURLOPT_RANGE, "0-5000"); I started looking around and found that using the custom write function I might be able to do the same. As I understand it, closing the handle and thus...
5
9574
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 configuration.. but there is an issue.. i see the following.. Configuration File (php.ini) Path C:\Windows Loaded Configuration File C:\php\php.ini PHP in installed to C:\php and the php.ini ONLY exists in that location and the permissions for...
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.