开发者

How to use FTP with ajax?

Let's say I'm connecting to an FTP by sending an ajax request to PHP开发者_运维知识库:

$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);

After this request I want to upload a file:

$upload = ftp_put($connection, $dest, $source, $mode);

Is there a way to keep an FTP connection to the server on the client side and keep sending ajax requests to it without reestablishing the FTP connection on the server side?

Thank you!


Hmm.. the only way that comes to mind is forking the PHP process, and then modifying some shared resource (file, shmem, etc) to pass messages to/from the AJAX process and the long-running FTP process.

But to be quite frank, you might want to reconsider your problem/tool combination here. It feels a bit like the old addage "If all you've got is a hammer, every problem starts to look like a nail". PHP's main strength is that it is specifically geared towards handling a single request and cleaning up all resources it claimed after handling the request. Other languages/platforms are more persistent, and might be more suitable for what you're trying to do here. I'm thinking along the lines of Java or .Net here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜