Re: php downlaod script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hulf wrote:
My download script only gives me empty (0kb) xls files. They are being uploaded as blobs and seem ok. Can someone shed some light on why the downoad is not working.

Many Thanks,


R.


<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database

$id    = $_GET['id'];
$query = "SELECT id, file_name, size, type, content FROM results WHERE id = '$id'";

$result = mysql_query($query) or die(mysql_error());
list($id, $file_name, $type, $size, $content) = mysql_fetch_array($result);

header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file_name");
header("Content-Length: ".filesize($size));
header("Accept-Ranges: bytes");
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-transfer-encoding: binary");


exit;
}

?>

Were are you actually outputting the $content???

is $size the actual size of the data?  if so, you don't need to run filesize($size)


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux