复制具有特定扩展名php4的文件
我正在编写一个小脚本,将一个目录中具有特定扩展名的文件复制到另一个目录。 目前我有:复制具有特定扩展名php4的文件,php,copy,Php,Copy,我正在编写一个小脚本,将一个目录中具有特定扩展名的文件复制到另一个目录。 目前我有: <?php $targetDir = "D:\\test dir\\"; $files = glob("C:\\old dir\\*.txt"); foreach ($files as $tocopy) { copy($tocopy, $targetDir); } ?> 您还需要将文件名添加到目标。类似于以下内容的内容应该会有所帮助 $targetDir = "D:\\test d
<?php
$targetDir = "D:\\test dir\\";
$files = glob("C:\\old dir\\*.txt");
foreach ($files as $tocopy) {
copy($tocopy, $targetDir);
}
?>
您还需要将文件名添加到目标。类似于以下内容的内容应该会有所帮助
$targetDir = "D:\\test dir\\";
$files = glob("C:\\old dir\\*.txt");
foreach ($files as $file) {
copy($file, $targetDir . $file);
}
我在“系统”php标记中使用xcopy进行复制 您还需要将文件名添加到目标中。正如Ben所说,添加文件名copy($tocopy,$targetDir.$tocopy)代码>相同的结果。我可以打印结果,它会提取两个.txt文件。当涉及到复制位时,它实际上不会复制文件:(相同的结果。我可以打印结果,它会拾取两个.txt文件。当涉及到复制位时,它实际上不会复制文件:(