I'm having a problem getting my PHP download script to work with special alphabetical characters like "æøå" which are not in the english alphabet. Files which include these letters can't be found and I am wondering if there is some kind of encoding problem. The files are stored on a windows machine running XAMPP.
$getFile = $_SESSION['base'].$_GET['file'];
$getFile = mb_convert_encoding($getFile, "UTF-8");
if (file_exists($getFile)) { //Retrives the file in path $getFile
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($getFile).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($getFile));
readfile($getFile);
exit;
}
The string assigned to $getFile can look like this "files/projects/Abrahallen/administrasjon/Exempel på admin.txt"
So when file names with special characters are requested the file_exists does not find a file and if I comment out the if statement I get this error message
Array
(
[file] => /Exempel på admin.txt
)
files/projects/Abrahallen/administrasjon/Exempel på admin.txt
Warning: filesize(): stat failed for files/projects/Abrahallen/administrasjon/Exempel på admin.txt in C:\xampp\htdocs\files.php on line 16
Warning: readfile(files/projects/Abrahallen/administrasjon/Exempel på admin.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\files.php on line 17