r/PHPhelp • u/Most_Will_9449 • Mar 19 '26
PHP can't read file path after newest update
I have this accounting program using PHP scripts that I've made but now I updated it at a customer to 8.4.6 it stopped being able to read out the paths I give. It worked 8.2.7 and previous versions.
I have this error call using file_exists and that triggers now since the update, I tried removing it to see if that was somehow causing the issue, but that isn't helping either instead it claims a bit later that the path doesn't exist.
I don't think it's the code because this code does work perfectly on my computer with the same PHP version. The security has also not changed.
Does anyone have an idea what could be wrong?
9
u/-PM_me_your_recipes Mar 19 '26
It is difficult to help without the exact error message you see, and the code you think is causing the error.
7
u/colshrapnel Mar 19 '26
Can you please be a bit more descriptive in regard of that "isn't helping either"? How exactly it isn't helping? There is an error when you are trying to read a file without file_exists - right? So which error exactly? File not found, permission denied, anything else?
3
u/No_Candle_6133 Mar 19 '26
Post exact here. file_exists itself does not emmit an error itself. so an external factor is causing this.
3
u/HolyGonzo Mar 20 '26
Simplify things. Just create a blank script like this:
And make sure the path and filename are escaped properly and see what it outputs.
If it outputs false, then try again but go up one level in the path. For example, if you check "/path/to/file" and it returns false, check "/path/to" and keep going up until it returns true.
If it never returns true, then you have something blocking filesystem access.
8
u/martinbean Mar 19 '26 edited Mar 19 '26
Try line 42.
1
u/Big-Dragonfly-3700 Mar 19 '26
Are you trying to test for and access the file using a file system path or a URL?
1
u/Alexander-Wright Mar 19 '26
Please check the
open_basedir =parameter in the PHP configuration.If the configuration is different between the CLI and FPM, this would explain the differences in behaviour.
1
u/brianozm Mar 20 '26
File/folder permissions have changed, or settings have changed.
-3
u/lordspace Mar 19 '26
Paste the exact error message into chatgpt and see what it would say. The file exists function is core and can't break that easily. I bet a variable or the folder structure has changed a bit