Re: FTP a file from a page
| From: | Peter Wade | Date: | Mon, 04 Dec 2000 00:35:28 +0000 |
| Subject: | Re: FTP a file from a page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28492@lists.php.net to get a copy of this message | ||
From a few days ago...
Subject: Re: [PHP] FTP a file from a page On Thu, 30 Nov 2000, Richard Kirk wrote: I want to place a file (.zip as it happens) on a page and when the user clicks on the file, have the file FTP'd to them, as opposed to opening it in the browser. Do I prefix the file with ftp:// ? Do I have to reference my ISP FTP server? Either FTP or HTTP can be used for this purpose; whether or not the browser opens the file is pretty much out of your hands regardless of which protocol you use. From: "Slavko Dervisevic" <slavkod@EUnet.yu> there is a nice solution with wrong headers: Header("Content-Type: something/wrong"); Header("Content-Disposition: attachment; filename=".$fname); $fp=fopen($fname,"r"); fpassthru($fp); it works!Slavko, can you give an example of how to use this. Should I put it in a function? What I am trying to do is this: I have RealAudio files and these work fine for streaming. I want to have a separate link where people can download them to their hard drive to listen to later, but most browsers insist on playing them in real time. So I want to fool the browser and allow the file to be saved to disk. Perhaps headers can help here? Preferably I'd like to pass the file name in a link to a "download page" and include the PHP code so it can be used with any file, much like many of the shareware listing sites do. Perhaps have the user click a "Download Now" button to start the transfer. Mark Lipscombe posted this a few days earlier, which might be the clue to what I am trying to do...
Subject: RE: [PHP] Forcing Download of a .jpg file in IE The correct way to ask a browser to offer to save the file for the user, rather than display it inline, is via the Content-Disposition header (RFC2183). You would do it like this: Header ("Content-Type: image/jpeg"); /* Content-Length is not necessary, but if you supply it, the user will see how * big the file is, and, presumably, how far they are into the download */ Header ("Content-Length: " . $contentlength); Header ("Content-Disposition: attachment; filename=suggestedfilename.jpg"); readfile("myimage.jpg");My only other thought is to somehow read the file from the server, change the suffix from .ra to .zip before passing to the user, and instruct the user to manually change the suffix after the download is complete -- very messy. I do not want to put two separate files on my server (e.g. one .ra and one .zip) as eventually I will run out of server space. Zipping a RealAudio file saves very little space, perhaps 3%. Any help from any one appreciated. Peter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hear Peter Wade & Norman Campbell live January 2001:
Halls Gap, Victoria, Australia.Biblical insights for you at the Positive Words site:
< http://www.posword.org/ > < http://i.am/in.Christ/ >Free newsletter... email to <subscribe@posword.org> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~