Forum Moderators: coopster

Message Too Old, No Replies

Keeping FTP connections open

in PHP

         

adb64

3:05 pm on Feb 3, 2006 (gmt 0)

10+ Year Member



I'm using PHPs FTP functions to transfer files etc to another server from an interactive environment. So I can put and get files, delete files, rename files etc. and after each action the PHP scripts displays the FTP UI.
Currently for each action I do the following steps:
  1. Open connection
  2. Login
  3. Do action (delete, rename, ...)
  4. Close connection

Is it possible to keep the connection open, doing step 1 and 2 only for the first action and skip them for all consecutive actions and step 4 only when I'm ready with all actions?

Thanks,
Arjan

Birdman

9:14 pm on Feb 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you have multiple ftp actions taking place during each execution of the script, then you can just ftp_close after all of them.

I don't think you can keep a persistent ftp connection across multiple script executions.

adb64

7:49 am on Feb 6, 2006 (gmt 0)

10+ Year Member



The last one is what I'm looking for, keeping the connection open across multiple script executions. Would it be possible to pass the connection handle (from the open command) as GET parameter on through the next script call?

coopster

6:50 pm on Feb 6, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



No, it would not. The reason being is that HTTP is a stateless protocol which means you connect to the server, the server processes the request, the server sends a response back, and finally the connection is closed. So, you won't be able to carry that across multiple requests.