tags:

views:

19

answers:

1

[QUOTE=php_lover;4343082]Hi all , I've writen a piece of code downloading file from mysql , here is the code :

php code :

$query = "SELECT name, type, size, content ,downloaded FROM ".filtering($cat , 'str')." WHERE id = '".filtering($id , 'int')."'";

$result = mysqlquery($query) or die('Error, query failed !!!');
list($name, $type, $size, $content, $downloaded) = mysql_fetch_array($result);

header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");

echo $content;
exit;
}

nothing is fail , when I try this script on my local machine the download window appears to me that where I whould download the file but when I try it on my server the download window won't appear and the content of file is shown on browser

for example when I want download .rar file these codes appear exchange of downloading window :

EVئ€#%   ئ€"%   èï‹ ‹}3غYئD0 C‹uhSC Vèڈ …ہYY…¢   9E„=‏ےے…ےj^‰uüŒQ‏ےےےujXè(üےے…ہY…=‏ےے…ےtےu3ہےuèûےےYYé%‏ےے‹Mٹ‹ٌë<:tFٹ„ہuُ€> „µ   ‹ئ+ء=   r¸ے  P‹Eےu¬  Pèظ‹ ‹EFVئ€«   è›چ ‹M‹uƒؤ‰پ¬  hSC Vè^ژ …ہYY…ئ   9E„†‎ےے…ےj[‰]üŒ‎ےےVjXèsûےے…ہY…‎ےے…ے…†  hSC ے
+1  A: 

Use the Content-Type value application/octet-stream to force the download:

The recommended action for an implementation that receives an "application/octet-stream" entity is to simply offer to put the data in a file, with any Content-Transfer-Encoding undone, or perhaps to use it as input to a user-specified process.

Gumbo