Page 1 of 1

php7 file_exists not working ?

Posted: 23 Feb 2021 13:52
by exxos
This was working on the current (this) server..

Code: Select all

echo "file_exists ".file_exists($file)."<BR>" ;
But on the new server with php7.4 it doesn't return anything at all, just totally blank.. anyone know whats going on with it ?!

Re: php7 file_exists not working ?

Posted: 23 Feb 2021 13:56
by exxos
Oh nevermind..

$file= "./DOWNLOAD/file.txt" doesn't work anymore.

$file= "/DOWNLOAD/file.txt" doesn't work anymore.

$file= "DOWNLOAD/file.txt" Does :roll:

Re: php7 file_exists not working ?

Posted: 23 Feb 2021 15:50
by thorsten.otto
file_exists() works on local filenames of the server, so you have to prepend the directory part of $_SERVER['SCRIPT_FILENAME'] when you want to use an absolute path (or $_SERVER['DOCUMENT_ROOT'], if your script is in the toplevel directory). Relative pathnames are always troublesome; the current directory may not always be the same as where the script is located.