Re: php downlaod script

From: Date: Tue, 25 Sep 2007 15:08:51 +0000
Subject: Re: php downlaod script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-262454@lists.php.net to get a copy of this message
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

« previous php.general (#262454) next »