I have an upload script which stores files on a specified directory on my C: drive and then stores the location and filename inside the DB which works with no problems - The insert statement looks like this
$sql = \"INSERT INTO coursework_table (fileloc, filename, filesize, filetype, user_id, upload_id) VALUES ( \'$fileloc\', \'$file_name\', \'$file_size\', \'$file_type\', \'$user_id\', \'$upload_id\') \";
$result=mysql_query(\"$sql\");
Fileloc is defined as $fileloc = \"/files/work/$file_name\";
I am confused on how to create a download script to download an uploaded file from my server based upon the upload_id.
I am a newbie, so take it easy on me :-)
At the moment, when i click on \'download\', the filename and path are displayed in the browser! and the file obviously does not dowload.
I have tried out the following script, but i get no joy, can anybody please help?
$query = \"select fileloc, filetype from upload_table where upload_id=\'$upload_id\' \";
$result = mysql_query(\"$query\");
$data = mysql_result($result,0,\"fileloc\");
$type = mysql_result($result,0,\"filetype\");
header ( \"Content-type: $type\");
echo $data;