Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

download script problem

Status
Not open for further replies.

vlakas1981

Programmer
Dec 11, 2002
40
GR
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.
 
yes i have. i also have tried application/save but to no differrent result. i have noticed that this problem is not always the same. for no obvious reason some filenames appear correctly in the text box, but others do not. the filename in the messagebox however is always wrong, it is the name of the web page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top