1

I'm creating an FTP browser with jQuery (see Does anyone know of a jQuery FTP browser plugin? for history). I'm writing the server-side code that is interfaced with an Ajax call via jQuery. I don't want to keep logging in (on the server side) and CWD'ing around.

Any thoughts?

Community
  • 1
  • 1
Shamoon
  • 41,293
  • 91
  • 306
  • 570

1 Answers1

2

My first thought is that storing the connection in a session variable won't work because the code effectively exits, destroying the connection. If I am wrong in that, there would be your answer :-D

If I am right, you could think about a single (php) program ('service'), that keeps on running, which maintains the ftp connections, and provides an interface to these connections through (for instance) a socket connection. This connection only accepts local connections!

Your jQuery->Ajax call will start a new php program (of course), does some authentication and security checks (quite important), connects to the 'service' described above and communicates whatever is needed.

Alternatively, you could replace Ajax for a javascript-socket connection directly to the 'service'. Again, security is an important issue! I don't know if jQuery can help you out with that, I do believe Google has some libraries for this though.

Jochem
  • 2,995
  • 16
  • 18
  • The problem with a service is that if it's PHP, it can't keep on running (without eventually dying). If you have multiple connections per user times multiple users, it'll crap out nice and early. I have to see more about creating a socket directly via JavaScript. – Shamoon Apr 29 '11 at 15:54
  • I don't see why a PHP program should die eventually. You can run php also from the command line as well. You would have to do that with the service. – Jochem May 01 '11 at 18:25