0
我有一些問題,下面的函數是假設複製整個目錄及其內容 - opendir行返回無法打開每一次,我不知道爲什麼。該源確實存在,並且擁有755個權限(也嘗試了757個權限,但仍然沒有運氣!)。PHP copydir功能問題
任何人都可以提出任何建議嗎?
function copydir($source,$destination)
{
if(!is_dir($destination))
{
$oldumask = umask(0);
mkdir($destination, 0757); // so you get the sticky bit set
umask($oldumask);
}
$dir_handle = @opendir($source) or die("Unable to open");
while ($file = readdir($dir_handle))
{
if($file!="." && $file!=".." && !is_dir("$source/$file")) //if it is file
{
copy("$source/$file","$destination/$file");
}
if($file!="." && $file!=".." && is_dir("$source/$file")) //if it is folder
{
copydir("$source/$file","$destination/$file");
}
}
closedir($dir_handle);
}
爲什麼在php中這樣做?操作系統是這樣做的:'exec(cp source dest);' – JvdBerg
它是一個基於php的服務器,我沒有訪問權限,除非通過ftp,所以真的需要一個php解決方案 – Jason
刪除'@'讓你看到實際錯誤消息 –