我已经使用以下代码在上传后解压缩邮政编码。
/* here it is really happening */
if(move_uploaded_file($source, $targetzip)) {
$zip = new ZipArchive();
$x = $zip->open($targetzip); // open the zip file to extract
if ($x === true) {
echo $targetdir; exit;
$zip->extractTo($targetdir); // place in the directory with same name
$zip->close();
unlink($targetzip);
}
$message = "Your .zip file was uploaded and unpacked.";
} else {
$message = "There was a problem with the upload. Please try again.";
}
它工作正常。但是唯一的问题是该文件夹被上传的新文件夹替换。我想合并它。
假设我有一个zip文件夹。一个 A b c
上传此内容时,它应与已经在上传服务器中的(一个)文件夹合并。因此,不应更换(一个)文件夹中的先前文件夹。
我认为现在可以理解。请帮助解决这个问题。
您可以con-cat当前时间&与您约会的目标名称:
$targetdir = $targetdir."_".str_replace(' ',"/",date('Y-m-d H:i:s'));
使用此逻辑,您不会用以前的文件替换。