Keep in mind that SCRIPT_FILENAME might not be available or consistent in certain environments. Nor will the system folder always be one level above the index.php that instantiated ExpressionEngine - it could be anywhere. What is the reason you need the server path to location EE was instantiated from?
I wanted to check to make sure an uploaded image existed and display a “slug” based on whether it was on the disk or not. I have to get into the uploads directory to check for the existence of the file, so I need to know the path of the EE instance. Is there a better way to do this with EE? I’m teachable.
What if that location doesn’t exist? You’d be much better off utilizing EE’s file upload locations. This will give your module greater flexibility, and allow easy access to the path, no matter what the user does with it on their installation. The Wiki module is a good example - in the configuration, you can select which file upload location you wish to use for uploads. If you need a head start on the code to interact with it, that would be a good module to look at.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.