This question has been asked many times, but none of the answers I found helped me.
I am trying to get php file_exists () to work. The only scenario when it works is when the php file is in the same directory as the file to use file_exist (), and only using the file name (i.e. excluding the path). But this is not consistent behavior, see below.
Information about Som:
- safe_mode = off
- no symbolic links for directory 28
- no spaces in file name
- All directories in / var / www / html / smic / upload / 28 / have apache: apache 777 as permission.
- Using php 5.3
PHP:
echo getcwd() clearstatcache(); $file = 'file:///var/www/html/smic/upload/28/ul.txt'; //Also tried like this //$file = '/var/www/html/smic/upload/28/ul.txt'; if(file_exists($file)){ echo $file." exists"; }
getcwd () prints / var / www / html / smic / modules / core / ticket
The php script permission and the file to be checked are apache: apache 777.
Some directory structure information:
[ root@localhost 28]
The behavior did not change after changing the file resolution. The / 28 directory has drwxr-xr-x. for apache user and apache group
For the test, I also moved the actual php script to / 28, gave it apache: apache 777 rigths. Changed the $ file to "ul.txt" (i.e. $ File = 'ul.txt';). This works, the ul.txt file is found.
getcwd () then prints / var / www / html / smic / upload / 28
As another test, I tried to find another file, excluding the path in the "ticket" directory, this file was not recognized.
I hit my head ...
Any advice is appreciated.
source share