tags:

views:

93

answers:

2

Hi,

I have developed a recursive FTP-download script, in PHP5, that allows you to select some files and/or directories to download using an AJAX request. The POST-variable that the server receives is just a short pipe-separated string that does not take up any memory at all.

The script itself works perfectly on my local Apache setup and goes into each directory and downloads every single file and folder.

On my remote virtual server which is set up under Media Temple the script fails on large structures, that is handled great by my local Apache.

The symptoms is that some directories are considered to be files and therefore the script won't step into them and download further.

The script checks whether or not a path is a directory by trying to open it remotely. If it can open the directory it recursively downloads everything in it until it finishes.

The php.ini that is hosted on Media Temple has a much higher threshold than the one on my local setup (longer max execution time, higher memory limit etc.) so that's not the issue... I have even tried using my local php.ini on the remote server.

Tailing the error log used to get my "Premature end of script headers, PHP" until I switched to a dedicated virtual server from regular hosting. Now it doesn't react at all.

What I've tried to solve the issue is experimenting with different values in php.ini and most recently I did a flush() and ob_flush() for every new file and directory that was created... in an attempt to stop any occurance of "Premature end of script headers, PHP".

Do you have any ideas?

A: 

Maybe it's an access issue: are you running on Linux? Is the VM the same as your dev-box? Does the user running apache have enough rights to read the directory?

Deefjuh
The server is running Linux CentOS 5 and my dev box is running Ubuntu 9.04. Rights doesn't seem to be the problem... I was unclear in the description. It works perfectly for a while. Some files and directories are downloaded as all well. But after a while some directories are considered to be files and the script ends with a lot done, but far from all.
Christoffer
A: 

Well basicly i don't know how your code is looking like, but that part here (from the php.net maillinglist) is working fine on my server. Maybee you can give us an example of your code?

Dennis
Thank you, that will speed things up a bit... Running a test right now to see if that is enough to make the script work as intended...
Christoffer
Hmm... The new code you provided gives the exact opposite result. In the beginning everything is working fine and then everything starts being downloaded as folders. (Epiphany! Doh! The FTP-connection is probably closed without the script noticing it :S Will get back to you when I find out)
Christoffer
Yes, now it works... But it's still waaaay slower than my local setup which is about 20 times faster.
Christoffer