var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
PHP: Help! Concurrent ftp uploads.
I'm trying to mirror some files from one dedicated box with PHP and FTP
I want the files to upload concurrently to different servers
instead of uploading to one server at a time.
Any gurus know how to do this? Thanks!
my code has been like:
$conn_id = ftp_connect("iphere");
// login with username and password
$login_result = ftp_login($conn_id, "username", "pass");
// upload the file
$upload = ftp_put($conn_id, "/files/blah.bah","blah.bah", FTP_BINARY);
// close the FTP stream
but this only uploads one at a time. I was thinking forking but then
I read forking isnt supposed to be used with webservers? Any help is appreciated!
And thus you hit the problem where php isn't a fulll programming language. Don't get me wrong, I love it, but these things stuck.
But if you get your host to compile pnctl stuff in, you can use threads.
- 30 Day 100% Satisfaction Guarantee -
Over 5 Years Going Strong!
, PHP4&5, RoR, MySQL 5.0, Reseller Hosting, Development, and Designs
Powered By JAM -
Professional Website Development
i figured it out using system
something along the lines of
system("php blah.php args >/dev/null &"
where blah.php uploads by ftp and is run in the background.
Assuming you have shell access:
I would have just used a shell script, no reason to use php for something like this
Assuming your host supports FXP, you could FXP the files.
If your host does not provide shell access, then i probably would have used perl and done a simple fork()
Since these operations are blocking (which means, execution stops till the operation is complete) you need to use threading -- as mentioned above, or fork the process to the shell.
PHP is not really the best when it comes to this kind of stuff unless you have pntl compiled, and even then its a bit flaky.
In order to understand recursion, one must first understand recursion.
If you feel like it, you can read my
Signal > Noise