Ok...i've pulled my hair out enough...someone should be able to answer this now...
I'm working on a simple script that uploads a file to a medium blob on a mysql server.
When I upload some files ( mainly pdfs, some excel, and text files) I am able pull the data out of the database write it out to a file and it works perfectly. Other files (images, word docs, etc...) upload fine, download fine, but are unreadable. What baffles me are that the file I uploaded and the file I downloaded are exactly the same size....wait, I just discovered that when my downloaded file is written I am getting an extra space as the first character. When I remove the space in vi the files work perfectly, but I can't figure out where it's coming from. I tried trim on the data before and after putting the data in the database and it didn't change the output, which leads me to believe the the problem is with the script that outputs the file. Here's the code:
<?php
require ('classes.inc.php');
require ('constants.inc.php');
$id = $_REQUEST['id'];
$doc = new fileStorage($id);
$size = $doc->get_filesize();
$type = $doc->get_mimeType();
$name = $doc->get_filename();
$content = $doc->get_data();
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
echo $content;
exit;
?>
does anyone see anything obviously wrong with this?
Thanks.