PHP Managing Files

Hi Chaps,

I have a PHP app that allows users to login and view contents of an FTP folder (that is unique to their login).
They can upload and download files but some users are having problems.

As some of the files can be quite large, the app seems to be a bit tempremental when uploading files.

Also, when downloading very large files, sometimes in excess of 200-300 Mb, the script seems to timeout. The script reads the file to be downloaded, then loads it to the header, to force open/download. But again, this is very tempremental and there’s nothing much to go on in terms or trouble-shooting. Everytime I test it, it seems to work, but users are having trouble.

I have checked the Windows IIS 7/PHP file settings, and all are OK.

So my questions are:

  1. what is the best way to handle very large file uploads?
  2. what is the best way to force open/download of large files, without PHP having to ‘read’ the file first?

Any help or guidence would be most appreciated.

Cheers

Sounds like you need to start logging things to a text file or DB table. Also register_shutdown_function could be quite useful for logging the current stream position when the failure occurs.

Hi, what would I be logging:

Sounds like you need to start logging things to a text file or DB table

Requested file, file path you’ve put in the header, size of the file, file path you’ve put in the header, file name, file path you’ve put in the header…

Also have you checked the file downloads for any text/html output? - Try opening them in a text editor and looking for text that you can recognise. This is a common error and is usually caused by a error in the code or whitespace in the php somewhere.

Debugging download scripts can be very hard thats why you have to become inventive about your debugging methods. I’ve had a download script that threw every conceivable problem at me and I still managed to outsmart it… You’ll understand its dead again now but thats besides the point :stuck_out_tongue: