Skip to content
Advertisement

Tag: directory

Create a folder if it doesn’t already exist

I’ve run into a few cases with WordPress installs with Bluehost where I’ve encountered errors with my WordPress theme because the uploads folder wp-content/uploads was not present. Apparently the Bluehost cPanel WordPress installer does not create this folder, though HostGator does. So I need to add code to my theme that checks for the folder and creates it otherwise. Answer

Get parent directory of running script

In PHP, what would be the cleanest way to get the parent directory of the current running script relative to the www root? Assume I have: $_SERVER[‘SCRIPT_NAME’] == ‘/relative/path/to/script/index….

Advertisement