Re: link to a pdf file

From: Date: Fri, 16 Nov 2001 13:24:48 +0000
Subject: Re: link to a pdf file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74855@lists.php.net to get a copy of this message
This works for what I do: Try this and fiddle with the variables. $conn_id is your pointer to an FTP connection. Familiarize yourself with the FTP functions in PHP if there are any doubts. PART I: Put this in one script (say "pdf_list.php"): // list server contents if ((!$F) || ($F=="")){ $dir_list = @ftp_nlist($conn_id, ""); if (!empty($dir_list)){ while (list($lvar, $lvalue) = each($dir_list)){ $S = @ftp_size ($conn_id, $lvalue); echo "$lvalue&nbsp;&nbsp;$S&nbsp;&nbsp;[<a href=\"download.pdf%20.php?F=http://$ftp_server/$my_dir$lvalue&S=$S\">DOWNLO AD</a>]<br>"; } } else { echo "No files available!<br>"; } } PART II: And save this as a separate file ("download.pdf .php"): <==observation: there is a space in this file name. See above: "%20"! <?php //You can submit $Dir, $File_Name, $File_Extension by another script adapting to your needs. header("Server:Keep-Alive"); header("Accept-Ranges: $S-$S/$S"); header("Content-Length: $S"); header("Content-disposition: filename=$F"); header("Content-type: application/force-download"); readfile("$F"); ?> Payment can be made with a thousand blondes from the Netherlands: in bikinis - no camels accepted! (Fine print: "they must be pretty - the girls, not the camels!") "Sjoerd Van Oosten" <SvOosten@esites.nl> wrote in message news:C9F89DA57491D511BDAF00E0180C348103BFCC@ESADM01... > Hello, a question again. > > I have a pdf file which can be downloaded. How can i link to this file so, > that the file isn't opened in the browser (if acrobat reader is installed) > but the file download popup appears? > > Greetings, > > ________________________________________ > Sjoerd van Oosten > Digitaal vormgever svoosten@esites.nl > Datamex E-sites B.V. > http://www.esites.nl > Minervum 7368 Telefoon: (076) 5 730 730 > 4817 ZH BREDA Telefax: (076) 5 877 757 > _______________________________________ >

« previous php.general (#74855) next »