I know I can just upload the file to a folder in my server, save the directory location to the MYSQL database, and create a download link based on that directory location but what happens when you store a file like a pdf or zip archive directly on the MYSQL database? How do you retrieve that data and create a file download link then?
3 Answers
You will have to set some content headers before outputting the data from your database, like:
header("Content-type: $type");
header("Content-length: $size");
header("Content-Disposition: attachment; filename=$name");
header("Content-Description: PHP Generated Data");
echo $data;
Full example at http://onlamp.com/pub/a/php/2000/09/15/php_mysql.html?page=3