1

I have checked that file_exists do not support special character.

My system need to check users' submitting files. And a file name has included dash character which make Internal Error 500. And users insist on not changing file name to work with the system.

Here is the PHP code:

$file_location = $db->user_file_path; // path: /path/to/user/file/file-name.pdf
if(!file_exists($file_location))
{
    // send email to user
}

How can I handle this case?

Jacky Shek
  • 953
  • 1
  • 11
  • 35
  • possible duplicate of http://stackoverflow.com/questions/2685718/special-characters-in-file-exists-problem-php – Thamilhan Oct 26 '15 at 04:27
  • I have tried, but not work for me – Jacky Shek Oct 26 '15 at 04:28
  • What is "spacial character"? Honestly, a dash isn't that special. Maybe one of the hyphens that lie outside the ASCII range could require that you encode the file properly, but none of that explains what's going on. – Ulrich Eckhardt Oct 26 '15 at 06:41

1 Answers1

2

Try realpath

The realpath() function returns the absolute pathname.

This function removes all symbolic links (like '/./', '/../' and extra '/') and returns the absolute pathname.

realpath() returns FALSE on failure, e.g. if the file does not exist.

Harshit
  • 5,147
  • 9
  • 46
  • 93