[PHP] Downloading very large files
I have an application that delivers files to the client browser. These files a very large video files. 250mb+ each. I have two options: 1) I could have PHP deliver the file with "fread", or 2) I could have PHP present a link to the file. However, for security purposes, I would rather not have the actual files available. I suppose I could have PHP create temporary symbolic links on the file system that link to the files in question and then remove the links, thus requiring the users to go through an authentication process to retrieve files that are assigned to them. Anyway, downloading such large files causes PHP to balk with size limitation errors. I could increase the size limit and memory limit settings in "php.ini", but for file sizes that large, is it recommended? Are there "best practice" limits on these settings: max_input_time, memory_limit, max_execution_time, etc.? Thanks, Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Downloading very large files
I've seen this problem many times before, but I'm not sure what solution was found. Possible solutions: Encrypt the file, make it publicly available, and then give the right people the encryption key. Put it behind a .htaccess file allowing only the IP of the correct person - remove the .htaccess entry after a certain lengh of time. Why are the videos secure? Copyright? Privacy? Bandwidth? On 2/13/06, Jonathan Duncan <[EMAIL PROTECTED]> wrote: > I have an application that delivers files to the client browser. These > files a very large video files. 250mb+ each. I have two options: 1) I > could have PHP deliver the file with "fread", or 2) I could have PHP > present a link to the file. However, for security purposes, I would > rather not have the actual files available. I suppose I could have PHP > create temporary symbolic links on the file system that link to the files > in question and then remove the links, thus requiring the users to go > through an authentication process to retrieve files that are assigned to > them. > > Anyway, downloading such large files causes PHP to balk with size > limitation errors. I could increase the size limit and memory limit > settings in "php.ini", but for file sizes that large, is it recommended? > Are there "best practice" limits on these settings: max_input_time, > memory_limit, max_execution_time, etc.? > > Thanks, > Jonathan > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Downloading very large files
Thank you for the input. For now we are just using PHP to create symbolic links to the video files and the links are removed when they are done viewing the video. We are open to other suggest still, but for now, this fills our needs and bypasses putting so much stress on PHP as to put hundreds of mb of files through it. Why secure? A combination of all those reason. Thanks, Jonathan On Mon, 13 Feb 2006, Rory Browne wrote: I've seen this problem many times before, but I'm not sure what solution was found. Possible solutions: Encrypt the file, make it publicly available, and then give the right people the encryption key. Put it behind a .htaccess file allowing only the IP of the correct person - remove the .htaccess entry after a certain lengh of time. Why are the videos secure? Copyright? Privacy? Bandwidth? On 2/13/06, Jonathan Duncan <[EMAIL PROTECTED]> wrote: I have an application that delivers files to the client browser. These files a very large video files. 250mb+ each. I have two options: 1) I could have PHP deliver the file with "fread", or 2) I could have PHP present a link to the file. However, for security purposes, I would rather not have the actual files available. I suppose I could have PHP create temporary symbolic links on the file system that link to the files in question and then remove the links, thus requiring the users to go through an authentication process to retrieve files that are assigned to them. Anyway, downloading such large files causes PHP to balk with size limitation errors. I could increase the size limit and memory limit settings in "php.ini", but for file sizes that large, is it recommended? Are there "best practice" limits on these settings: max_input_time, memory_limit, max_execution_time, etc.? Thanks, Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Downloading very large files
Jonathan, Not sure how you're using fread, but here's a slightly modified version of what's in the manual that might help: If my understanding of this code is correct you won't be trying to load the entire file into memory and you're not trying to store the file in a variable. All that this should do is give the client the file in 8KB chunks - which is much easier on the overall load your script will add to the system and will probably run faster since it's not as taxing. Again I've never had to write a script that matches your conditions but I hope this helps. -Joe W. www.joewollard.com - theCore On 2/13/06, Jonathan Duncan <[EMAIL PROTECTED]> wrote: > > Thank you for the input. For now we are just using PHP to create symbolic > links to the video files and the links are removed when they are done > viewing the video. We are open to other suggest still, but for now, this > fills our needs and bypasses putting so much stress on PHP as to put > hundreds of mb of files through it. > > Why secure? A combination of all those reason. > > Thanks, > Jonathan > > > On Mon, 13 Feb 2006, Rory Browne wrote: > > > I've seen this problem many times before, but I'm not sure what solution > was > > found. > > > > Possible solutions: > > > > Encrypt the file, make it publicly available, and then give the right > people > > the encryption key. > > > > Put it behind a .htaccess file allowing only the IP of the correct > person - > > remove the .htaccess entry after a certain lengh of time. > > > > Why are the videos secure? Copyright? Privacy? Bandwidth? > > > > > > On 2/13/06, Jonathan Duncan <[EMAIL PROTECTED]> wrote: > > > >> I have an application that delivers files to the client browser. These > >> files a very large video files. 250mb+ each. I have two options: 1) > I > >> could have PHP deliver the file with "fread", or 2) I could have PHP > >> present a link to the file. However, for security purposes, I would > >> rather not have the actual files available. I suppose I could have PHP > >> create temporary symbolic links on the file system that link to the > files > >> in question and then remove the links, thus requiring the users to go > >> through an authentication process to retrieve files that are assigned > to > >> them. > >> > >> Anyway, downloading such large files causes PHP to balk with size > >> limitation errors. I could increase the size limit and memory limit > >> settings in "php.ini", but for file sizes that large, is it > recommended? > >> Are there "best practice" limits on these settings: max_input_time, > >> memory_limit, max_execution_time, etc.? > >> > >> Thanks, > >> Jonathan > >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Downloading very large files
On Mon, Feb 13, 2006 at 03:27:32PM -0700, Jonathan Duncan wrote: > I have an application that delivers files to the client browser. These > files a very large video files. 250mb+ each. I have two options: 1) I > could have PHP deliver the file with "fread", or 2) I could have PHP > present a link to the file. However, for security purposes, I would > rather not have the actual files available. I suppose I could have PHP > create temporary symbolic links on the file system that link to the files > in question and then remove the links, thus requiring the users to go > through an authentication process to retrieve files that are assigned to > them. > > Anyway, downloading such large files causes PHP to balk with size > limitation errors. I could increase the size limit and memory limit > settings in "php.ini", but for file sizes that large, is it recommended? > Are there "best practice" limits on these settings: max_input_time, > memory_limit, max_execution_time, etc.? Well if things are done correctly, the only thing that may become an issue is max_execution_time. The basic logic for sending a file with php is: // authenticate the user (if they can download this or not) // send headers, like content-length, content-type, // content-disposition etc. // set_timelimit(0); if the user is on a slow connection.. // ignore_user_abort(false); see below // use either readfile() or fpassthru() // if this line is executed the user has mantained a connection so // far, so you are pretty much sure they recieved, or it is a PEBCK // issue, you can do things like add a successful counter or // something here. HTH, Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php