Hey folks, I'm very new to php, coming from an ASP.NET background. I've been all over these here interwebs the past 3 days trying to solve this problem, but I can't seem to get it figured out!
I've got a small app that's uploading images to a mySQL database. That part's working fine and dandy: with mySQLAdmin I'm able to see that the images are in there a-ok. The problem lies with retrieving them. I've put all the header information in the proper places, but when I run the php script, all I see are broken links. Additionally, a right-click of the image shows no header information.
I'm able to download the images to my PC, but Windows File viewer won't show anything. If I open the file in Photoshop, I get a warning about corrupt data, but the picture opens anyway!!
What's going on here? Have I missed setting up something in my local install of php/mySQL/apache (remember, I'm a noob, but I've installed and re-installed each of them following all sorts of directions!).
A master download php page calls this "child" page with id=xx in the querystring:
<?php
if(isset($_GET['id']))
{
include 'library/config.php';
include 'library/opendb.php';
$id = $_GET['id'];
$query = "SELECT picName, picType, picSize, picContent FROM headshot_db WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($picName, $picType, $picSize, $picContent) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename= ".$picName);
header('content-name: '.$picName);
header('content-length: '.$picSize);
header('content-type: '.$picType);
echo $picContent;
include 'library/closedb.php';
exit;
}
?><php>
Running WinXPsp2, Apache 2.2, MySQL 5.0, PHP 5.
Thank you very much!!!