[英]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. 此路径:将“ \\ 192.168.1.8 \\ data \\ CATEGORY_LIMIT \\ 1027 \\ JPN \\ 1027_1.0.indd_tmp”复制到“运行”->“输入”->“访问确定”。 Why folder_exist not working? 为什么folder_exist不起作用? How check exist folder? 如何检查存在的文件夹?
It looks like you are accessing a remote share (on machine 192.168.1.8), not a local file. 看来您正在访问远程共享(在机器192.168.1.8上),而不是本地文件。
You might try the built-in function file_exists() instead. 您可以尝试使用内置函数file_exists()。 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. 它应该支持网络共享检测,尽管我不希望php以与本地文件夹相同的方式处理网络共享。
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) 通常,我将网络共享安装为本地文件夹,因此可以使用标准路径访问它们(例如,在Linux中的/ etc / fstab中或Windows中的映射驱动器中)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.