![]() |
|
[PHP] How do I point to the root web directory in this code? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [PHP] How do I point to the root web directory in this code? (/showthread.php?tid=5962653) |
How do I point to the root web directory in this code? - Babadook - Apr 21, 2019 I need this code set to where it starts from the root directory of my site. I use this both locally and externally so I need it to work for both. I've tried all of these: PHP Code What works: PHP Code However, I can't use this as the file is used in multiple directories with differing lengths from the root. I can set it to use the files in the local directory just fine. But I can't get it above the directory. When I do this with $dir it breaks the image and doesn't display "Temporary.jpg" while trying to grab "mysite.com/var/www/html/uploads/Photos/MovieCovers/5th%20Passenger%20(2018)@2x.jpg". $dir2 and everything else shows temporary image and Specific line i want pointed to '/uploads/Photos/MovieCovers/*.{jpeg,jpg,png,gif}': PHP Code Full Code: PHP Code RE: How do I point to the root web directory in this code? - Disease - Apr 21, 2019 (Apr 21, 2019 02:27 PM)Babadook Wrote: I need this code set to where it starts from the root directory of my site. I use this both locally and externally so I need it to work for both. Typically you'd define this as a constant, or via a configuration library/object, during instantiation of your application. In other words, you might define this via index.php, before requiring in relevant files as a result of the web request. PHP Code Alternatively, you could define this as an environment variable on the machine itself (supposing you have access to do that). You can then retrieve that during execution via the getenv() function. PHP Code RE: How do I point to the root web directory in this code? - Babadook - Apr 21, 2019 (Apr 21, 2019 03:29 PM)Disease Wrote: Typically you'd define this as a constant, or via a configuration library/object, during instantiation of your application. In other words, you might define this via index.php, before requiring in relevant files as a result of the web request. Thank you. I'll look into everything after work tomorrow! RE: How do I point to the root web directory in this code? - .trigious - Apr 23, 2019 Don't use HTTP_HOST as directory source. It can be controlled by attackers and can lead to path traversal attacks if you are not on a shared hosting environment. :) |