Browser - Upload of file to remote 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
myitanalyst
Forum Newbie
Posts: 24
Joined: Wed Dec 14, 2005 4:31 pm

Browser - Upload of file to remote server

Post by myitanalyst »

Hello,

Currently I am helping develop a website using PHP and mySQL on the backend... using unix servers at my host.

I have a standard form that allows the user to fill in general information and so forth that will by saved in a PHP database.

The user must attach an audio file .mp3 which is normally around 15MB, but could be smaller or larger.

Here's the tricky part, this file needs to go to an offsite storage server at Limelight. Basically limelight is a storage provider that does caching and has multiple points of presence for fast access.

Anyway, I need to know how or get some direction on the best way of going about doing this. It seems like I may need a very rich web interface and have the file directly ftp'd to the Limelight site instead of sending it to my host (where the form and web pages are) and then having the backend some how send it to limelight.

I look forward to your wisdom and thoughts.

Greg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

having the browser directly send it to the servers could easily compromise the security of them. I would definitely recommend sending the files from your web host after they have been uploaded.
myitanalyst
Forum Newbie
Posts: 24
Joined: Wed Dec 14, 2005 4:31 pm

Post by myitanalyst »

feyd wrote:having the browser directly send it to the servers could easily compromise the security of them. I would definitely recommend sending the files from your web host after they have been uploaded.
I am relatively new to PHP... how would one go about doing this? Basically the only interface to the Limelight server I have is FTP.

The other concern is having the browser timeout when sending let's say a 15MB file to my host which in turn would then send it up to limighlight. Can I control the timeout values?

I basically am trying to avoid manual uploading via an FTP client because the folks using this interface need it dumbed down as much as possible so it is foolproof.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP has FTP interaction functions to automate FTP functions. As for timing out, the transfers are handled, overall, automatically once started. Standard internet traffic can cause hiccups and errors, but they are normally handled by the browser and/or server. Now, this doesn't protect against real connection issues with networks such as linkage failures.
myitanalyst
Forum Newbie
Posts: 24
Joined: Wed Dec 14, 2005 4:31 pm

Post by myitanalyst »

feyd wrote:PHP has FTP interaction functions to automate FTP functions. As for timing out, the transfers are handled, overall, automatically once started. Standard internet traffic can cause hiccups and errors, but they are normally handled by the browser and/or server. Now, this doesn't protect against real connection issues with networks such as linkage failures.
Here is a general flow that has been suggested to m:
- a person uploads file to your server (I assume this is using normal HTML and form upload OR should I use a third component that would handle this and give some feedback on the progress to the user????)
- the file is stored in a temporary directory, e.g., /tmp/limelight/
- the server transfers the file via FTP
- the transfer is done via a cron job, a cron job is basically a script that can be run at a set interval, the script would likely:
- transfer a file(s) via FTP
- after the file is transfered it will delete the file in /tmp/limelight/ (or maybe you don't want to delete it, who knows)
- be sure to log transfers and send emails for errors
- be sure to have a lock file to prevent multiple instances of the cron script running
Would you or others agree with this general guidline? Thoughts, changes, additions, other recommendations.

Thank you!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I would recommend implementing a queue (maybe just a data table) to which the uploader adds records and from which the FTPer gets its jobs and marks them as transfering or done. That would also give you a log of the uploads/transfers as well.
(#10850)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Sounds fine to me however, I would generally suggest moving the file outside of the upload directory as many servers are configured to clear temporary directories often.

move_uploaded_file()
myitanalyst
Forum Newbie
Posts: 24
Joined: Wed Dec 14, 2005 4:31 pm

Post by myitanalyst »

arborint wrote:I would recommend implementing a queue (maybe just a data table) to which the uploader adds records and from which the FTPer gets its jobs and marks them as transfering or done. That would also give you a log of the uploads/transfers as well.
Would you mind expanding this thought just a bit.
myitanalyst
Forum Newbie
Posts: 24
Joined: Wed Dec 14, 2005 4:31 pm

Post by myitanalyst »

feyd wrote:Sounds fine to me however, I would generally suggest moving the file outside of the upload directory as many servers are configured to clear temporary directories often.

move_uploaded_file()
Someone replied on another forum and said the php file upload stuff couldn't handle files larger than 2MB. I don't know if this is exactly accurate or if the point is there will be problems with larger files.

Most of these files will be 10 to 15MB in size and could be larger at times.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The default limit is 2MB, but it can be changed through various means to allow for much larger file uploads. Read how file upload handling works in the manual: http://php.net/features.file-upload It talks about the directives that affect the limits.
myitanalyst
Forum Newbie
Posts: 24
Joined: Wed Dec 14, 2005 4:31 pm

Post by myitanalyst »

feyd wrote:The default limit is 2MB, but it can be changed through various means to allow for much larger file uploads. Read how file upload handling works in the manual: http://php.net/features.file-upload It talks about the directives that affect the limits.
You know... I am finding the online manual extremely valuable. Just trying to find everything and knowing what to look for.

I wonder if the HOST can limit the upload in PHP or can you always override it.

Thanks again for your assistance, you have been most helpful.
Post Reply