php – 如何在从zip文件解压缩到特定位置之前检查文件夹是否已存
发布时间:2020-12-13 22:29:22 所属栏目:PHP教程 来源:网络整理
导读:$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); 如果已经存在,如何避
$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 } 更新
AFAIK,您无法覆盖文件夹.但是你可以覆盖一个文件.要查看目标文件是否已存在,请使用 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |