我使用PHP來檢查文件是否存在,然後獲取它的大小。文件存在但使用UNC路徑返回「系統找不到指定的文件」
代碼之前工作很好,但現在我們正在使用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
?>
我以爲你把它與引號,但我用雙引號添加包圍$文件名,並沒有幫助。我不確定我能夠在服務器上運行它,必須與服務器組對話,但我一定會牢記這一點。謝謝@EKW! – mario 2015-03-26 21:07:40
@ gv0000增加了一個關於我今天早上注意到的另一個錯誤的提示,我強烈建議使用PHP交互式shell(這就是讓我注意到另一個bug的原因......如果我按照自己的建議開始...... ) – EKW 2015-03-30 16:02:32