Displaying files from database

From: Date: Wed, 28 Mar 2007 17:41:23 +0000
Subject: Displaying files from database
Groups: php.general 
Request: Send a blank email to php-general+get-251551@lists.php.net to get a copy of this message
Hi. I'm storing an uploaded file into a MySQL database. I want the file to then be downloaded and viewed. Uploading looks like: <snippet> if (is_uploaded_file($file) && $filename) { $handle = fopen ($file, 'r'); $resume["data"] = base64_encode (fread ($handle, filesize ($file))); fclose($handle); $resume["type"] = $_FILES['resume']['type']; $resume["size"] = $_FILES['resume']['size']; } </snippet> It loads into the database fine. If it's a word document, it merely spits out plain text. If it's a PDF, it says it can't open it. Downloading looks like: <snippet> $app = applications ($_GET["id"]); header ("Status: 200 OK"); header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header ("Content-Length: ".$app["size"][0]); header ("Content-Type: ".$app["type"][0]); header ("Content-Disposition: attachment; filename=Resume-".$app["full"][0]); echo $app["resume"][0]; exit; </snippet> What am I doing wrong?!! =D Thanks in advance. ~Philip

« previous php.general (#251551) next »