作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
$zipfile = 'zipfilename';
$extractpath= 'C:\extract';
$zip = new ZipArchive();
if ($zip->open($zipfile) !== TRUE) {
die ("Could not open archive");
}
// extract contents to destination directory
$zip->extractTo($extractpath);
如果文件夹已经存在,如何避免覆盖?
最佳答案
$extractpath = '/somewhere/someplace/';
if (is_dir($extractpath) AND file_exists($extractpath)) {
// Path exists
}
Actually I want to avoid overwriting a folder while unzipping?
AFAIK,您不能覆盖文件夹。但是你可以覆盖一个文件。要查看目标文件是否已存在,请使用 file_exists()
(与 is_file()
一起使用可能也是明智的)。
关于php - 如何在从 zip 文件解压缩到特定位置之前检查文件夹是否已经存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4283150/
我是一名优秀的程序员,十分优秀!