I try to download a file from FTP server into client. If I use ftp_get
, the file is downloaded into PHP server, which can write the output into browser. So the download process is
FTP server -> PHP server -> client
This doubles traffic - this is bad in downloading big files. There is a way how to write the file directly into the browser described here: Stream FTP download to output - but the data flows through PHP server anyway, am I right?
Is there any way how to establish this download (if yes, how?), or is it principially impossible?
FTP server -> client
Edit: it should work also with non-anonymous FTP servers in secure way.
<a href="ftp://server/file.ext">Download the file</a>
;-)If the client can directly access the file in question (i.e. no secret usernames or passwords necessary), just redirect him to it:
This will cause the client to access the URL directly. You can't control what the client will do though. The browser may simply start to download the file, but it may also launch an FTP client or do other things which you may or may not care about.
try below code for that.
Thanks.