0
我的問題是,我正在嘗試使用PHP copy()將index.html文件從一個目錄複製到我的Web應用程序中的另一個目錄。 它可以複製,當他們在相同的目錄,但當我嘗試複製到另一個目錄與chmod 777權限,然後什麼都沒有發生。 以下是我的src代碼。我想將文件夾template1中的index.html複製到另一個名爲users的文件夾,但它不會複製。將文件從一個目錄複製到同一個域中的另一個目錄是行不通的。
CopyIndexHtml.php
<?php
$src='./builder/template/template1/index.html';
$des='./builder/users/index.html';
copy($src,$des);
?>
檢查日誌後。檢查'copy()'的返回值。不要使用相對路徑,而要使用絕對路徑:'__DIR__。 '/../ path/to/builder/...'' –
你可能想檢查拋出的錯誤。複製後:'$ errors = error_get_last(); echo $ errors ['message'];' – varlogtim
@RuslanOsmanov感謝您的建議,感謝它,歡呼 – LKH