tags:

views:

43

answers:

3

Hi,

I would like to start a upload and download website for huge files (up to 1gb). I thought that it would be better to download the files using FTP (with PHP), because this protocol is especially used for these types of transfers.

The cliënt gets an email, including a download link to download the file (like yousendit.com). When they click on the link a download box appears. My problem is that I don't know how to show a download box using ftp and php. I have read that it isn't possible to immediately download a file by PHP, using FTP. Is this correct? Do I have to create a temporary files on the server to let the client download the file? If yes, is this also a good solution for huge files?

What do you advice me to give the clients the possibility to download these huge files?

Thanks for your reply!

A: 

Can't you send them an FTP link ? Why do you need PHP?

ftp://ftp12.freebsd.org/pub/FreeBSD/ls-lR.gz

Byron Whitlock
The files need to be protected, so clients can't download files from others. With a direct ftp link it is also possible to download other files on the server.
Jaap
A: 

You can generate unique address based on session_id (create this folder on runtime and move huge file there) and redirect user to this link For example, you have file huge.tgz

1. Send you client link http://***/user/john/file/huge.tgz
2. Ask user for auth in this page if they lost session
3. get session id
4. create on your server folder with name equals session id and move huge.tgz here
5. redirect user to unique ftp link ftp://***/17oe5kf8iYmpt66bjs89hcuo83/huge.tgz

You should disallow list files and directories on ftp server

ifrond
hmm, how long does it take to move a file to a unique location? And how can you redirect the user to a ftp location? By header('Location: ftp://.....'); ? And the user has the possibility to download the file more than once.
Jaap
if the file is on the same server and partition - less then a second. And yes with php header function or javascript location.href
ifrond
If you don't want to move file. You can copy it. It takes some minutes. By ajax request server if file is ready (size of file in unique dir equals size on original file) and than redirect by javascript
ifrond
The only thing I have to do is deleting files when they are downloaded or isn't downloaded anyway. Hmm, the files has to be ready when the user opens the link, so copying a file isn't the solution I'm afraid.
Jaap
A: 

You probably want to use PHP to handle everything but the file transfer. Once you have done all the checks you want you can redirect the browser to the file specifying the protocol as ftp. though you won't be able to have a progression bar in your site, the browser/ftp app will probably display one.

araf3l
But in your case users can be download other files on the server when they know the filename, right? Is it better to connect to the ftp server using php?
Jaap