Hi,
I've managed to successfully upload files into a BLOB field in a MySQL database.
However, when attemting to download the files using PHP, the files are always corrupt.
I have verified that the uploaded files are not corrupt by using a perl script to extract the files from the BLOB field.
Any ideas why the files are corrupted when downloading via PHP?
My code is as follows:
<?php
include "session.php";
session_write_close();
$FILE_ID = $GET['FILE_ID'];
$FILE_NAME = $GET['FILE_NAME'];
$FILE_TYPE = $GET['FILE_TYPE'];
$FILE_SIZE = $GET['FILE_SIZE'];
header("Content-Transfer-Encoding: binary");
header("Content-length: $FILE_SIZE");
header("Content-type: $FILE_TYPE");
header("Content-Disposition: attachment; filename=$FILE_NAME");
include "db-connect.php";
$SQL_SELECT_FILE = "SELECT FILE FROM FILE WHERE FILE_ID = '$FILE_ID'";
$viewSQL = mysql_query($SQL_SELECT_FILE);
$FILE_FILE = mysql_result($viewSQL, 0, 0);
echo $FILE_FILE;
?>