I am currently trying to check with PHP if a file exists. The current file that I am trying to check if it exists contains an apostrophe, the file is called: 13067-AP-03 A - situation projetée.pdf.
The code I use to check if a file exists:
$filename = 'C:/13067-AP-03 A - Situation projetée.pdf';
if (file_exists($filename))
{
echo "The file exists";
} else
{
echo "The file does not exist";
}
The problem that I am facing right now is that whenever I try to check if a file exists, I get a message that it does not exist. If I continue deleting é, I get a message that the file exists.
It seems that PHP somehow does not recognize the file if it has an apostrophe. I tried the following:
urlencode($filename);
addslashes($filename);
utf8_encode($filename);
None of them worked. I also tried:
setlocale(LC_ALL, "en_US.utf8");
, , PHP, :
13067-AP-03 A - projet e.pdf
, :
$filename = iconv( "CP437", 'UTF-8', $filename);
, - . .
, , script Windows.
: Sublime Text 3 . , PHP.
, , , , :
13067-AP-03 A - Situation projet e.pdf
, , , file_get_contents. file_get_contents .