Check If Folder Exists Is Not Working

Wednesday, November 4, 2015

I'm trying to get this function to recognize if a folder exists on the server, but it's not working. I've tried is_dir function as well but no luck.



This script is trying to be utilized in a Wordpress plugin, but it's using the php-based function to look if a file/folder exists. Any idea why it's not recognizing that the /docs folder exists? I've verified that $filename is actually pulling up the correct file path on server.



function docs_settings_page() {
$filename = get_stylesheet_directory_uri()."/docs/";
if(file_exists($filename)) {
echo "The folder exists!";
}
else {
echo "Sorry - the file does not exist.";
}
}

function docs_create_menu() {
// Do stuff here
}

add_action('admin_menu', 'docs_create_menu');

0 comments:

Post a Comment