A script to redirect data to FTP server

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
qritari
Forum Newbie
Posts: 5
Joined: Fri Jul 22, 2005 3:16 pm

A script to redirect data to FTP server

Post by qritari »

Hi,

I currently have a webhost hosting my entire website. Recently, I set up my own FTP server. I have created a HTML form for users of my website to upload (possible as big as 100MB) huge files. While this files will reside on my webhost server, I would like the data to be transferred to my FTP server as well, or even by passing the webhost altogether. I was told by a friend that a good script on the webhost server may do the trick. Is there anyone who could provide more insight to this?

Thanks!
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

PHP has FTP functions that you can use to establish a connection with your home server. See http://us2.php.net/manual/en/ref.ftp.php

You could also set up Apache and PHP on your own server, and then simply have the form's action link point to the PHP page that handles uploads on your own server.
qritari
Forum Newbie
Posts: 5
Joined: Fri Jul 22, 2005 3:16 pm

Post by qritari »

Hi there,

thanks for replying. Actually, I posted the same question on section of this forum (cos I didn't know exactly where the question should go). Anyway, I was told, with thanks, to refer to the php manual. While I'm at it, I got a few more questions:
"Is there also a way to upload huge files via html forms in this case? my webhost just told me that the size limit per unload is 2MB. This is not really useful. After googling around and refering to the php manuals, it seems like uploading 20MB causes problems too. Any comments regrading this?

I know FTP clients will do fine with huge files, but isn't there a straight forward way to get HTML and PHP to do the job?"
This is a quote from my question in the other section.

Thank you.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Ah, shared hosting. That might present a little bit of a problem. You see, the solution you're looking for, in the end, will still entail some sort of communication between the servers. It doesn't matter what protocol, be it FTP, HTTP, SMTP etc, the limits will still apply, or you'll time out, or something.

For HTTP uploads, there are two levels of safety given: an Apache limit on upload size and a PHP limit on upload size. Since you don't have access to the configuration files, you can try a combination of ini_set() http://us2.php.net/manual/en/function.ini-set.php and htaccess files to change your configurations around so this is allowed. It might not work, ex, they may not have htaccess allowed.

What you could also do is, with 7zip, compress and split up the files into manageable chunks. That's doable too. With some batch scripts and local php files, you can automate the process too.
Post Reply