troubleshooting Question

PHP -- create and use a code library

Avatar of Glen Gibb
Glen GibbFlag for Canada asked on
PHPWeb Servers
8 Comments2 Solutions282 ViewsLast Modified:

I'm trying to create a set of reusable objects to use in my websites.  No problem as far as the coding, but I'm confused by absolute and relative path names.

I get the $SERVER['DOCUMENT_ROOT'] business, and I can move up a level with ../ .  

This code: " $action = $_SERVER['DOCUMENT_ROOT'] . "/tools/add_image.php";" produces a 404 error.  (But the file does actually exist at the path specified.)

Modifying it thusly: "$action = "/tools/add_image.php"; works from one directory, but not from another further down the tree.  That needs $action = "../tools/add_image.php";

I need to call a POST from somewhere down the tree and have it directed to a page at the document root.

How do I consistently access a file at the document root, or even better, a library folder even further up the tree?

Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros