Apache

Moderators: None (Apply to moderate this forum)
Number of threads: 150
Number of posts: 335

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
PHP to Download File from Web Server ? Posted by melissa_may1 on 12 Apr 2007 at 8:06 AM
This message was edited by melissa_may1 at 2007-4-12 8:7:44

Hi All:

I'm sure you all can clear up my confusion easily!

What happens between the webserver and the client when the user types a URL that returns a data file? As a result of typing the URL, the browser pops up a "File Download" dialog, and asks "Do you want to open or save this file?"

Here's what I'm trying to do: I want to automate the download of a data file that I get from a webserver daily. Now I manually download the data file to my workstation, then run a program that parses the data file and puts the data into a MySQL database.

I have a webserver with Apache and MySQL and PHP all set up.

I have a PHP script that I use for users on a website to upload files to the server, but that's not what need...

Can I use PHP to do this? Can anyone give me some tips on where to start? I'm so confused!

Thanks!


Melissa


Report
Re: PHP to Download File from Web Server ? Posted by PrzemekG_ on 13 Nov 2007 at 2:23 PM
: This message was edited by melissa_may1 at 2007-4-12
: 8:7:44


: Hi All:
:
: I'm sure you all can clear up my confusion easily!
:
: What happens between the webserver and the client when the user
: types a URL that returns a data file? As a result of typing the URL,
: the browser pops up a "File Download" dialog, and asks "Do you want
: to open or save this file?"
:
: Here's what I'm trying to do: I want to automate the download of a
: data file that I get from a webserver daily. Now I manually download
: the data file to my workstation, then run a program that parses the
: data file and puts the data into a MySQL database.
:
: I have a webserver with Apache and MySQL and PHP all set up.
:
: I have a PHP script that I use for users on a website to upload
: files to the server, but that's not what need...
:
: Can I use PHP to do this? Can anyone give me some tips on where to
: start? I'm so confused!
:
: Thanks!
:
:
: Melissa
:
:

If you have a linux workstation, place a script in /etc/cron.daily/ or configure your /etc/crontab to point to your downloading script.


in PHP:
#!/usr/bin/php
$data = file_get_contents("http://address.to.data/myData.file");
file_put_contents("/tmp/myData.file", $data);
system("php my_data_processing_script.php /tmp/myData.file");


in shell script:
#!/bin/sh
wget http://address.to.data/myData.file -O /tmp/myData.file
php my_data_processing_script.php /tmp/myData.file

Report
Re: PHP to Download File from Web Server ? Posted by spw2000 on 18 Aug 2009 at 5:51 AM
Very elegant - wish i was working on a Linux workstation - am stuck with a windows one instead but your solution is exactly what i need for my situation - how does your solution translate in to Bill Gates World???

Forget the scheduling - i am battling to get the code to download a file - all my attempts seem to get a file from the server and put it on the same server.... :(



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.