download.php
} else {
$filename = NULL;
}
$err = '<div align="center">GREEK error msg</div>';
if (!$filename) {
// if variable $filename is NULL or false display the message
echo $err;
} else {
// define the path to your download folder plus assign the file name
$path = '../downloads/'.$filename;
// check that file exists and is readable
if (file_exists($path) && is_readable($path)) {
// get the file size and send the http headers
$size = filesize($path);
header('Content-Type: application/octet-stream;');
header('Content-Length: '.$size);
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
// open the file in binary read-only mode
// display the error messages if the file can´t be opened
$file = @ fopen($path, 'rb');
if ($file) {
// stream the file and exit the script when complete
fpassthru($file);
exit;
} else {
echo $err;
}
} else {
echo $err;
}
}
?>
and this is how I call it:
<a href="scripts/download.php?file=GREEKCHARS_Earth.pdf"></a>
If file name is in English download script works ok.
If file name is in Greek it shows the error msg.If I echo $filename I see the correct Greek name so I suppose that the correct name is passed in my download.php.
Since I get the correct name with $filename and my actual file has the same name, where does the script fails to download my file and it gives me the error msg?
It seems that it fails to match the Greek $filename with the actual file.
";` outputs nothing. `echo bin2hex($filename) . "
";` outputs: cea42ece942e5f3039385f – Pavlos1316 Nov 22 '12 at 06:38