Re: trying to download birary data

From: Date: Sun, 30 Apr 2006 16:11:13 +0000
Subject: Re: trying to download birary data
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-235158@lists.php.net to get a copy of this message
Ross wrote:
On this page http://www.nationalservicesscotland.com/publications/a-z.php I use the following code to donwload binary data. It is jsut gibberish. I think the offending line is echo "<a class=\"pdflinks\" href=\"$link\"</a>$name</span>"; How do I recompile the binaryy data into docs and pdfs?
         <?
    $letter="a";
$query= "SELECT * FROM publications WHERE alphabet='$letter'"; $result= mysql_query($query); while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){
    $row['pdf_size'] = $row['pdf_size']/ 1024;
$row['pdf_size']= number_format($row['pdf_size'], 0); $size= $row['pdf_size']; $name = str_replace("_", " ", $row['pdf_name']); $name = str_replace(".pdf", "", $name); $link= $row['content']; echo "<a class=\"pdflinks\" href=\"$link\"</a>$name</span>";
$link should a link to a download script rather than the actual file data! something *like*: /dl.php?file_id=1 and your dl.php script should take the id select the content from your publications table and output that directly *without* any html being output... you will mostly like need to also output some suitable headers to tell the browser what it is/needs to do. - search this list for more info on suvh headers (or the web), similar questions have been answered repeatedly (so you should find something pretty quickly)
echo "&nbsp;&nbsp;"; echo "<span class=\"sizes\">($size kb)</span>"; ?><a href="a-z.php?id=<?=$row['id'];?>">link</a> <br> <? }


« previous php.general (#235158) next »