This time, it is about IE, PHP-file download with data from mysql and SSL.
When trying to download a file with my script "https://blabla.com/file-download.php?ID=12345" there are two errors showing:
1: The "Save as..." popup suggests the request string instead of the file name.
2: IE says "Can't find the page" after a few seconds of trying.
Note: This error only occurs with IE.
OF COURSE everything works perfectly with MZ and NS7.
Here is the faulty php script "file-download.php":
Code: Select all
<?php
session_cache_limiter('private');
define('NO_HEADERS',1); //tells functions.php not to send any headers.
define('IN_SYSTEM',1);
require "functions.php"; //connects to DB, defines some functions and starts the session.
//also, the "functions.php" secures $_GET with addslashes() (in case anyone dislikes the query below.)
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
$File = mysql_query_get_first_row("select distinct t1.*, t2.Txt as FileName from PermRead t3
left join Files t1 on t3.TodoID=t1.TopicID
left join Topics t2 on t1.TopicID=t2.ID
where t3.TopicID='{$_GET['ID']}' and t3.UserID = '{$_SESSION['LoggedInID']}' and t2.IsFile=1");
if ($File !== false){
header("Content-Length: ".$File['Size']);
header("Content-type: ".$File['MimeType']);
if ($BrowserIsGecko){
header("Content-Disposition: attachment; filename='".(str_replace(Array("Å","å","Ä","ä","Ö","ö"),Array("A","a","A","a","O","o"),$File['FileName']))."'");
}else{
header("Content-Disposition: attachment; filename="".$File['FileName'].""");
}
$Content = mysql_query("select Content from FileContent where FileID={$File['ID']} order by ID");
if (mysql_num_rows($Content)){
while ($Row = mysql_fetch_row($Content)){
echo $Row[0];
}
}
Accesslog("Downloading File");
}else{
Accesslog("File Download Failure");
echo '
<html><head><link rel="StyleSheet" href="main.css" type="text/css"></head>
<body><table height="100%" align="center"><tr><td valign="middle" align="center">
Error. The system could not find the file.<br><br><a href="overview.php?WhatNow=View">Go Back</a>
</td></tr></table></body></html>
';
}
?>