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?
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 😀
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.