使用PHP将文件从FTP服务器直接下载到浏览器 [英] Download file from FTP server directly to browser with PHP

查看:367
本文介绍了使用PHP将文件从FTP服务器直接下载到浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ftp_get()从FTP服务器下载文件并将文件保存到本地服务器。

因此,当我想从FTP服务器下载文件到我的浏览器时,该文件将首先下载到本地服务器,然后下载到浏览器。

p>

这会导致双重带宽。有没有办法直接从FTP下载文件到浏览器?

解决方案

ftp_get() curl 或任何PHP脚本都需要打开流源并将其传递给客户端浏览器。您仍然使用2个流,导致带宽使用率增加一倍。避免这种情况的唯一方法是链接到或让最终用户直接收集文件。



我假设您正在从专用FTP收集文件位置,传递凭证,并且您不希望最终用户拥有这些凭据,或者他们不知道他们。对他们来说,它应该是一个无缝的下载。



没有很多好的方法来做到这一点。在我看来,在终端用户浏览器中通过Flash进行FTP客户端连接是一种方法。您可以动态创建闪存或使闪存收集凭据(加密),然后从最终用户浏览器(在解密凭据后)执行到FTP服务器的连接,并将文件直接下载到最终用户。


ftp_get() downloads a file from an FTP server and saves the file to local server.

So when I want to download a file from an FTP server to my browser, the file will first be downloaded to the local server and then downloaded to the browser.

This causes double bandwidth. Is there a way to download a file from an FTP to browser directly?

解决方案

ftp_get() or curl or any PHP script will require opening a stream to the source, and passing it the client browser. You still use 2 streams, resulting in double the bandwidth usage. The only way to avoid this is to link to or have the end-user collect the file directly.

I am assuming that you're collecting the file from a private FTP location, passing the credentials, and you do not want the end-user to have these or they do not know them. Yet for them, it should be a seamless download.

Not a lot of good ways to do this. In my mind, making an FTP Client connection via Flash in the end-users browser is one way. You could dynamically create flash or have the flash collect the credentials (encrypted), and then perform the connection to the FTP Server from the end-users browser (after decrypting the credentials) and download the file directly to the end-user.

这篇关于使用PHP将文件从FTP服务器直接下载到浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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