php怎么得到绝对路径和相对路径文件并复制到一个目录中
时间:2021-07-01 10:21:17
帮助过:3人阅读
php如何得到绝对路径和相对路径文件并复制到一个目录中
无标题文档






如题:php如何得到绝对路径和相对路径文件并复制到一个目录中
我想得到html中相对路径或是绝对路径中的文件,并把这些文件复制,放在一个 images 目录中
php复制
php如何得到绝对路径和相对路径文件
分享到:
------解决方案--------------------$a = array();
$dir = '/var/www/html';
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (preg_match("/\.png$/", $file)) $a[] = $file;
elseif (preg_match("/\.gif$/", $file)) $a[] = $file;
}
closedir($handle);
}
foreach ($a as $i) {
copy($dir . '/' . $i, '$dir . '/images/' . $i);
}