简体   繁体   English

通过FTP从PHP通过PHP下载文件,就像通常下载文件一样吗?

[英]Download file via PHP from FTP, like normally downloading a file?

I am currently trying to retrieve a file from an FTP-Server in order to make it accessible for the user to download. 我目前正在尝试从FTP服务器检索文件,以使其可供用户下载。 ftp_get() writes it to a path on the local machine, yes, but what I want is that it also shows up in the download history and counts as "normal" download from the internet but I didn't figure out how to do this yet. ftp_get()将其写入本地计算机上的路径,是的,但是我想要的是它也显示在下载历史记录中,并且可以从互联网上算作“正常”下载,但是我不知道该怎么做然而。 I also tried to link directly to the file in PHP with header("Location: ftp://username:password@ftp.server.com/myfile.file") but this was resulting in the browser showing the files contents (which I didn't want). 我也尝试使用header("Location: ftp://username:password@ftp.server.com/myfile.file")直接链接到PHP中的文件,但这导致浏览器显示文件内容(我将不想)。 Did I miss any header -Parameters ? 我错过了任何header -Parameters吗? Or is there a completely different way to do this ? 还是有完全不同的方式来做到这一点?

You won't be able to "redirect" a user to a file so he can download it using FTP. 您将无法将用户“重定向”到文件,因此他可以使用FTP下载文件。 This is a HTTP-thing. 这是一个HTTP事物。 Browsers provides FTP features and make it look like HTTP but, in fact, those are different stuff. 浏览器提供FTP功能,使其看起来像HTTP,但实际上,它们是不同的东西。

If this file is only accessible through FTP and it is on a remote server, the only way I can imagine so you cand 'redirect' this download to the user is: 如果只能通过FTP访问此文件,并且该文件位于远程服务器上,则可以想象的唯一方式是将下载内容“重定向”给用户:

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM