Some more information from me
[man]file_exists/man
works with both directory AND file
returns TRUE if $filename is DIRECTORY or FILE, does not have to be readble/writable
We also have these alternative checking functions:
[man]is_file/man .. TRUE only if is file, FALSE if is directory or NOT exists
[man]is_dir/man .. TRUE only if is directory, FALSE if is file or NOT exists
[man]is_readable/man .. DIR/FILE exists AND is readable, FALSE if NOT exist or NOT readable
[man]is_writable/man.. DIR/FILE exists AND is writable, FALSE if NOT exist or NOT writable
The best check function to use, depends on the situation.
What you are trying to do.
Just checking file_exsist is not always a garantee for
you will have any use of this file/directory.
If you can not read from it .. for example.
The most accurate test can many times be:
1. if is_file( $filename )
2. if 1.= TRUE ... then CHECK is_readable( $filename ) / is_writable( $filename )
..... then is OKAY to try read/write
3. if 1.= FALSE OR 2.= FALSE ... then error message
Regards
halojoy
🙂