坚持跨AJAX调用FTP连接PHP资源 [英] Persist an FTP connection PHP resource across AJAX calls

查看:432
本文介绍了坚持跨AJAX调用FTP连接PHP资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多用户的PHP Web应用程序,可以通过AJAX一个FTP服务器进行交互。该应用程序允许浏览FTP站点用户。使用Javascript使一个AJAX调用它与服务器脚本返回指定目录中的文件和目录的列表进行通信。

这工作得很好。然而,一个目录列表被索取的时候,这个服务器必须重新建立与FTP服务器,这需要大量的时间连接。

我要坚持一个FTP连接PHP资源跨AJAX调用。换言之,该连接必须保持打开,并且我必须是(当然,直到连接超时,)能够运行ftp_nlist()使用该资源,而无需重新建立连接或重新认证,每一个新的AJAX调用

任何人都可以想办法做到这一点?

解决方案

我最终作出使用全局变量这项工作(如:$ my_global)

。我有管理存储在一个哈希连接的ConnectionPooler单例类。

I have a multi-user PHP web application that can interact with an FTP server via AJAX. The application allows the user to browse an FTP site. Javascript makes an AJAX call which communicates with a server-script that returns a list of files and directories within a given directory.

This works fine. However, each time a directory listing is requested, the server must re-establish a connection with the FTP server, which takes a lot of time.

I need to persist an FTP connection PHP resource across AJAX calls. In other words, the connection must remain open, and I must be able to run ftp_nlist() using that resource, without re-establishing the connection or re-authenticating, with each new AJAX call (until the connection times out, of course).

Can anyone think of a way to do this?

解决方案

I ended up making this work using global variables (eg. $my_global). I have a ConnectionPooler singleton class which manages connections stored in a hash.

这篇关于坚持跨AJAX调用FTP连接PHP资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆