简体   繁体   中英

Why check exists folder not working in php?

<?PHP
$path="\\\\192.168.1.8\\data\\CATEGORY_LIMIT\\1027\\JPN\\1027_1.0.indd_tmp";
if(folder_exist($path)){
                        echo "ok";
                    }
                    else
                    {
                    echo "No";
                    }
                    exit;
function folder_exist($folder)
{
    $folder = str_replace('\\\\', '/', $folder);
    // Get canonicalized absolute pathname

    $path = realpath($folder);

    // If it exist, check if it's a directory
    return ($path !== false AND is_dir($path)) ? $path : false;
}
?>

Result : No So I can't delete or rename this folder. This path: "\\192.168.1.8\\data\\CATEGORY_LIMIT\\1027\\JPN\\1027_1.0.indd_tmp" copy to Run -> Enter -> access ok. Why folder_exist not working? How check exist folder?

It looks like you are accessing a remote share (on machine 192.168.1.8), not a local file.

You might try the built-in function file_exists() instead. It's supposed to support network share detection, though I don't expect php to handle the network share the same way as a local folder.

Generally I mount the network shares as local folders, so can I access them with a standard path (for example in /etc/fstab in Linux , or mapped drive in windows)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM