【发布时间】:2015-03-26 18:15:03
【问题描述】:
我正在使用 PHP 检查文件是否存在,然后获取它的大小。
代码之前运行良好,但现在我们使用的是 UNC 路径,我可以使用 file(exists($filename)) 检查该路径是否存在,但是当我尝试运行 exec("getsize" . $filename, $out); 时,它会尝试运行大约一分钟,然后返回“该系统找不到指定的文件”。运行它的用户当前是管理员,否则我会认为这是一个权限问题,但我不确定如果它使用 file_exists() 查找文件但 exec() 失败还有什么问题。
任何帮助或积分将不胜感激,谢谢!
代码示例:
<?php
$filename = "\\\\server\\share\\file_path_with_folders\\3019-74 (2).zip"; //Example file
if(file_exists($filename)){
echo "File Exists: " . $filename . "\r\n";
// "File Exists: " . $filename" are getting echoed out, so it is succeeding
} else {
echo "File doesn't exist: " . $filename . "\r\n";
}
exec("getsize" . $filename, $out); //Runs command line command
//Getting "The system cannot find the file specified" error
echo "Out: " . $out[0] . "\r\n";
//Echos "Out: " and nothing else
?>
【问题讨论】:
标签: command-line php unc