We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

best way to access application root

Development and Programming

cwpollock's avatar
cwpollock
72 posts
16 years ago
cwpollock's avatar cwpollock

What’s the best way access the application root when developing a module.

I can’t rely on $_SERVER[‘DOCUMENT_ROOT’] because ee will not always be in the root directory of a domain.

       
cwpollock's avatar
cwpollock
72 posts
16 years ago
cwpollock's avatar cwpollock

Thank you! Very helpful

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

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?

       
cwpollock's avatar
cwpollock
72 posts
16 years ago
cwpollock's avatar cwpollock

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.

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Is this an image included as a supplied theme with your add-on, or something uploaded through the file upload utility?

       
cwpollock's avatar
cwpollock
72 posts
16 years ago
cwpollock's avatar cwpollock

My module is a “catalog manager”. Certain products have pictures and downloads associated with them. I’m placing the image in the standard “uploads” directory where all the images normally go when using the standard file upload utility.

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

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.

       
cwpollock's avatar
cwpollock
72 posts
16 years ago
cwpollock's avatar cwpollock

Ok thanks.. I’ll take a look.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.