php downlaod script

From: Date: Tue, 25 Sep 2007 13:22:44 +0000
Subject: php downlaod script
Groups: php.general 
Request: Send a blank email to php-general+get-262448@lists.php.net to get a copy of this message
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; } ?>

« previous php.general (#262448) next »