AFAIR, if you use file_exists
with relative paths, you have to be very careful, because the path is relative to script that is called by request and not relative to file that contains that check…
So if it’s a plugin and the request goes to main WP index.php, then you’ll be looking for a file in WP root.
But if the same code will be run by AJAX call (wp-admin/admin-ajax.php) it will search for that file in wp-admin directory.
That’s why you should use ABSPATH
or use __DIR__
(to make the path relative to file in which you check the file existence).