Hi:
The file_exists() does fail depending on the user running the script.
On the very same machine against the very same webERP installation:
- If a regular user (not admin) runs Z_ChangeStockCode.php it says "No image to rename".
- logout and login as admin user... it works perfectly. It finds the image and renames it.
- logut and login again an a 3rd user (not admin) and fails again.
To test the issue added these 4 lines just before the if file_exists() to snif the filesnames and in both cases are OK.
Code:
$oldfilename = $_SESSION['part_pics_dir'] . '/' .$_POST['OldStockID'].'.jpg';
$newfilename = $_SESSION['part_pics_dir'] . '/' .$_POST['NewStockID'].'.jpg';
echo ' OLDNAME ' .$oldfilename;
echo ' NEW ' .$newfilename;
So, it has to do with some privileges needed for file_exists().
Could you pls test it?