CREATE TABLE filetable (
ID int(10) NOT NULL auto_increment,
filedata mediumblob NOT NULL,
filedescription varchar(50) default NULL,
filename varchar(50) NOT NULL default '',
filesize varchar(50) NOT NULL default '',
filetype varchar(50) NOT NULL default '',
username varchar(45) NOT NULL default '',
PRIMARY KEY (ID)
) TYPE=MyISAM AUTO_INCREMENT=131 ;
I am able to upload a pdf or word or xls file to the page using some php code for file uploading. It is the same on both websites.
Now for my issue. I have a page where the files from the database are displayed and provide link for the user to open the file. The issue is that the code works on one site but not the other. The only difference I can tell you is the one that works is running php 4.0 and the one that doesn't work is running 5.0
Is there a change in the way 5.0 is executing this code. It is identical on both
Code: Select all
<?php
if ($id) {
include ("dbconnect.inc.php");
$sql = "SELECT * FROM filetable WHERE ID=$id";
$result = mysql_query($sql);
$result = mysql_fetch_object($result);
$username = $_COOKIE["user"];
header("Content-type: $result->filetype");
header("Content-length: $result->filesize");
header("Content-Disposition: attachment; filename=$result->filename");
header("Content-Description: PHP Generated Data");
echo $result->filedata;
}
?>