Heim >Backend-Entwicklung >PHP-Tutorial >PHP 如何判断映射目录是否存在?

PHP 如何判断映射目录是否存在?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:16:171318Durchsuche

PHP 如何判断映射目录是否存在?
如果存在,如何获得此目录的大小和修改时间
 
目录为(\\apguds\note\x-section\05C62\) 开始运行中可直接打开
不知道PHP中代码对于这个路径是要怎么写的,试了半天没成功 


回复讨论(解决方案)

你这个映射目录是否需要密码访问?

<?php// Define the parameters for the shell command$location = "\\servername\sharename";$user = "USERNAME";$pass = "PASSWORD";$letter = "Z";// Map the drivesystem("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");$dir = $letter.":/";// Check the directoryif(is_dir($dir) && is_readable($dir)) {    // 获取目录大小}

你这个映射目录是否需要密码访问?

<?php// Define the parameters for the shell command$location = "\\servername\sharename";$user = "USERNAME";$pass = "PASSWORD";$letter = "Z";// Map the drivesystem("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");$dir = $letter.":/";// Check the directoryif(is_dir($dir) && is_readable($dir)) {    // 获取目录大小}




我这个是不用密码的,可直接打开,现在就是想得到如何判断是否存在,因为是对分目录进行操作
然后存在就获得目录大小和修改时间
谢谢了

那你就这样用好了

<?php // Define the parameters for the shell command$location = "\\servername\sharename";$letter = "Z"; // Map the drivesystem("net use ".$letter.": \"".$location."\" /persistent:no>nul 2>&1"); $dir = $letter.":/"; // Check the directoryif(is_dir($dir) && is_readable($dir)) {    // 获取目录大小}

还是没有用,你这个是要创建一个映射盘? 我电脑好像没这个(运行后也没有创建个个),我是直接在运行输入后就可以打开的

<?php// Define the parameters for the shell command$location = "\\apguds02\mi_note\x-section\04c692";$letter = "Z"; // Map the drivesystem("net use ".$letter.": \"".$location."\" /persistent:no>nul 2>&1"); $dir = $letter.":/"; // Check the directoryif(is_dir($dir) && is_readable($dir)) {    echo '目录存在';}else{  echo '目录不存在';}?>


这个目录是存在的,可是输出是不存在, 另外存在的时候如何获得大小和日期啊 

看下效果图

不知道为什么,我用这个还是不行,已经用另一种方法解决了,
感谢你的一直关注的技术支持,希望社区多一些像你这样热心的人

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:关于引用变量的疑惑Nächster Artikel:微信公众平台接口