Need a script that downloads files from FTP automatically

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Glamophonic
Forum Newbie
Posts: 6
Joined: Wed Sep 01, 2010 6:04 pm
Location: Spain

Need a script that downloads files from FTP automatically

Post by Glamophonic »

Hi there!

I am not much into PHP or programming and stuff, but I just had an idea and wanted to know if that is possible to do!

What I wanna do is "install" or use a PHP script that automatically downloads X files from a FTP every X minutes and uploads them on another server! I guess that mustn't be difficult, but I have no idea! The other part I want to do (I guess this is more difficult) is, once X files are uploaded on the second server (not the original), create a page where everyone can download those files.


Sorry if I didn't explain myself well, but I suck at english!


Thanks in advance!! :-D
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: Need a script that downloads files from FTP automaticall

Post by Gargoyle »

won'T be much of a problem, just you will have use cron to call the PHP script as it can't magically spring to life on its own.
Glamophonic
Forum Newbie
Posts: 6
Joined: Wed Sep 01, 2010 6:04 pm
Location: Spain

Re: Need a script that downloads files from FTP automaticall

Post by Glamophonic »

Gargoyle wrote:won'T be much of a problem, just you will have use cron to call the PHP script as it can't magically spring to life on its own.
What's a cron? :oops:
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: Need a script that downloads files from FTP automaticall

Post by Gargoyle »

Glamophonic
Forum Newbie
Posts: 6
Joined: Wed Sep 01, 2010 6:04 pm
Location: Spain

Re: Need a script that downloads files from FTP automaticall

Post by Glamophonic »

Wow, thanks!!! :D
And how can I use it with PHP?

:/

Sorry for all these stupid questions but I know nothing about PHP/Cron!
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Need a script that downloads files from FTP automaticall

Post by shawngoldw »

Glamophonic wrote:And how can I use it with PHP?
When you set up cron you just tell it to run a specified script every X time interval. You just set that script to be a php file.
Glamophonic
Forum Newbie
Posts: 6
Joined: Wed Sep 01, 2010 6:04 pm
Location: Spain

Re: Need a script that downloads files from FTP automaticall

Post by Glamophonic »

shawngoldw wrote:
Glamophonic wrote:And how can I use it with PHP?
When you set up cron you just tell it to run a specified script every X time interval. You just set that script to be a php file.
How do I get that script (not cron) and where do I install it? I have found some online tutorials but I don't get anything at all :crazy:

:oops: :oops:

Thanks for your help!!
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Need a script that downloads files from FTP automaticall

Post by shawngoldw »

There is no "that script". You would need to write "that script" to do what you want. Then cron can take care of running it for you ever X minutes.

Now, since you said you are not much into programming this will be much more difficult to do :D But yes, it is possible.


Shawn
Glamophonic
Forum Newbie
Posts: 6
Joined: Wed Sep 01, 2010 6:04 pm
Location: Spain

Re: Need a script that downloads files from FTP automaticall

Post by Glamophonic »

shawngoldw wrote:There is no "that script". You would need to write "that script" to do what you want. Then cron can take care of running it for you ever X minutes.

Now, since you said you are not much into programming this will be much more difficult to do :D But yes, it is possible.


Shawn

:/ Thanks!

I'm def giving up! LOL
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Need a script that downloads files from FTP automaticall

Post by shawngoldw »

No problem, if you decide to give the script a shot, feel free to ask around here if/when you get stuck :wink:
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: Need a script that downloads files from FTP automaticall

Post by timWebUK »

http://php.net/manual/en/book.ftp.php

This may be of use to you. The PHP manual entry for FTP, containing all the functions you could call. Your script would need to contain several parts:

- A connection to the a server
- A get command to retrieve the file
- Store that file locally/temporarily
- A connection to the other server
- A 'put' command to send the local file you just download

If you are running on a Linux-based operating system you would then set up a 'crontab' file, which would contain the location of the script, and it will run it at intervals you specify. As you said you don't know much programming, this is would be a great challenge to get into PHP and learn your way around. Also a good Linux exercise.

Don't give up.
Post Reply