php7 file_exists not working ?

News,announcements,programming,fixes,game patches & discussions.
Post Reply
User avatar
exxos
Site Admin
Site Admin
Posts: 28613
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

php7 file_exists not working ?

Post 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 ?!
User avatar
exxos
Site Admin
Site Admin
Posts: 28613
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: php7 file_exists not working ?

Post 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:
User avatar
thorsten.otto
Posts: 148
Joined: Mon Nov 04, 2019 2:20 am

Re: php7 file_exists not working ?

Post 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.
Post Reply

Return to “SOFTWARE PROGRAMMING & DISCUSSION”