upload a zip file (e.g. foo.zip) to the server; the zip file contains files and directories
unzip the zip file on the server with the owner of the unzipped files and directories ending as ftp user (so they can be later deleted using regular FTP client)
Please note that permissions on the directory where the zip file is uploaded are 755 and the owner of the directory is ftp user.
Here is how I attempted to do it:
uploaded the zip file using ‘ftp_put’
uploaded ‘unzip.php’ file using ‘ftp_put’
called ‘unzip.php’ using curl; ‘unzip.php’ file is using ZipArchive::extractTo to unzip the file. The problem I am having with this approach is that the user the php script is running under do not have ‘write’ permission to the directory so ‘extractTo’ function fails…
I faced a similar situation to what you are describing a few months back on a system project that required auto downloading and parsing files. I ended up putting together a small application that did the job.
If you would like I can send you the files and instructions on setup. Hopefully it will be of some use to you.
vessio’s solution looks good but requires to manually change access permissions on the target server and this is what I am trying to avoid from maintenance and security point of view. The zip file will be uploaded to multiple servers… So for right now the only solution I can think of is to ftp every file in the zip file separately. It will work but will be much slower than 'ftp’ing zip file and unzipping on the target server. so I am still open for any advice.
Another solution is to install ftp server that has post-upload hooks. Basically you can configure the server to execute a script after the upload is complete.
I used pure-ftp server for exactly this type of task.