vlakas1981
Programmer
hello everyone.
i have a problem with my download script. it gets the filename and file from a mysql database, but when downloading the name seen in the download msgbox is the name of the url, and the filename given as default is an invalid, not having the correct extension, which ends up in saving the file as html file. This is a problem, since most of the files are word or pdf files. here's that part of the script:
mysql_select_db($database_sadaes, $sadaes);
$query_getfile =sprintf("SELECT articles.file, articles.filename FROM articles WHERE id= %s",
GetSQLValueString($HTTP_GET_VARS['id'], "int" ));
$getfile = mysql_query($query_getfile, $sadaes) or die(mysql_error());
$row_getfile = mysql_fetch_assoc($getfile);
$totalRows_getfile = mysql_num_rows($getfile);
$name=$row_getfile['filename'];
header("Content-Type: application/save"
;
header("Content-Disposition: attachment; filename=\"$name\""
;
header("Content-length: ".strlen($row_getfile['file']));
header("Content-Description: PHP Generated file"
;
header('Content-Transfer-Encoding: binary');
echo($row_getfile['file']);
thanks for your time.
i have a problem with my download script. it gets the filename and file from a mysql database, but when downloading the name seen in the download msgbox is the name of the url, and the filename given as default is an invalid, not having the correct extension, which ends up in saving the file as html file. This is a problem, since most of the files are word or pdf files. here's that part of the script:
mysql_select_db($database_sadaes, $sadaes);
$query_getfile =sprintf("SELECT articles.file, articles.filename FROM articles WHERE id= %s",
GetSQLValueString($HTTP_GET_VARS['id'], "int" ));
$getfile = mysql_query($query_getfile, $sadaes) or die(mysql_error());
$row_getfile = mysql_fetch_assoc($getfile);
$totalRows_getfile = mysql_num_rows($getfile);
$name=$row_getfile['filename'];
header("Content-Type: application/save"
header("Content-Disposition: attachment; filename=\"$name\""
header("Content-length: ".strlen($row_getfile['file']));
header("Content-Description: PHP Generated file"
header('Content-Transfer-Encoding: binary');
echo($row_getfile['file']);
thanks for your time.