Take the 2-minute tour ×

I need to implement Wordpress (or some other CMS) web site on Server_1 that when user upload files, they are transferred to another Server_2, there processed by some application and returned to Server_1 so user can download it or view. Because files can be large, I found that best solution would be FTP transfer, something like: http://www.designaeon.com/transfer-files-bw-servers-php When file is transferred, application on Server_2 should be started and after it process files they should be returned to Server_1.

So my question is: What is the best way to implement this?

Should I use php and ftp transfer and some listeners to check folder on Server_2 if file is processed or some external application that check folder every few minutes and copy to another servers files... I would appreciate any points on how to implement this and where to look.

Thank you in advance!

share|improve this question
How ive have achieved this in the past is to first chop up the file into 1mb chunks if files larger then 20mb then use curl_multi to POST all the chunks to a receiver script that assembles the pieces back together. It was faster then a single connection. Tho ftp is an option. –  Loz Cherone Sep 21 '12 at 12:55
Thank you for your quick response! I was trying last 2 days how to implement this, but no luck. Can you please show me some basic code, how can it be done one on sender and other on receiver side. Thank you very much. –  user1688686 Sep 24 '12 at 6:27
If you must transfer the files, I'd recommend rsync to move the files and an inotify-based script to trigger the processing. However, you could simplify your process greatly if you just uploaded to Server_2 directly and served the processed content from there. –  Ben Graham Sep 26 '12 at 0:58
Can this whole processing be done in the background or will the user be waiting for the results? –  Jack Sep 26 '12 at 3:05
user need to wait for the results –  user1688686 Sep 26 '12 at 8:39
show 1 more comment

1 Answer

This is one possible approach:

  1. On Server_1, host the freshly uploaded files in a secret, via http accessible folder.
  2. On Server_2, host a php that is capable of downloading, processing and outputting the file.
  3. When the file is being uploaded, put it in the accessible folder, then use curl or wget to query the php on Server_2 passing the URL to the newly uploaded file (i.e. wget http://server_2/path/to/processor.php?file=http://server_1/path/to/secret/dir/original.pdf)
  4. processor.php will then download the file, modify it and as a response write it back to the curl or wget process on Server_1
  5. Have that curl or wget process on Server_1 save the modified file to your desired location.
share|improve this answer
add comment

Your Answer


