0
<?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?

D T
  • 3,522
  • 7
  • 45
  • 89

1 Answers1

2

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)

Azzabi Haythem
  • 2,318
  • 7
  • 26
  • 32
Kevin Seifert
  • 3,494
  • 1
  • 18
  • 14
  • Yes. but i had shared folder – D T Aug 11 '15 at 14:13
  • php is going to look at your local file system, for a folder named something like c:/192.168.1.8/. That doesn't exist. – Kevin Seifert Aug 11 '15 at 14:14
  • I try create shortcut in C:\symlinks\data=\\192.168.1.8\\data. It still not working. How can check in this case? – D T Aug 11 '15 at 14:23
  • It's still not a local folder. Just because you can browse to a folder in Explorer doesn't mean the file exists on your local machine. Php is correctly determining that no such *local* folder exists on the machine. I think what you'll need to do is access the folder remotely using a network protocol (for example, using FTP, SCP, SSH, etc) – Kevin Seifert Aug 11 '15 at 14:26
  • The function file_exists can support network shares locations, though it wouildn't surprise me if this were not reliable. Two things that could break the function are permissions that php is running as, and the php.ini settings. – Kevin Seifert Aug 11 '15 at 14:31
  • Also, I notice you are using the function folder_exist(). I think you may want file_exists() instead – Kevin Seifert Aug 11 '15 at 14:43