1
我在PHP中解压缩zip文件并尝试将其重命名为content.txt。这里是我的代码:
if($this->copyFile($this->src,$this->dest)) {
$this->log .= "Successfully copied the file. Starting unzip.<br />";
$res = $this->zip->open($this->dest);
if ($res === TRUE) {
$this->zip->extractTo("/htdocs/content-refresh/");
$this->extracted = $this->zip->getNameIndex(0);
$this->log .= "Extracted ".$this->extracted." onto our server.<br />";
if($this->zip->renameIndex(0,'content.txt')) {
$this->log .= "Renamed update file to content.txt.<br />";
} else {
$this->log .= "Could not rename update file to content.txt.<br />";
}
$this->zip->close();
$this->log .= "The update file is ready to go. Now you can use the update functions.<br />";
} else {
$this->log .= "Could not unzip the file.<br />";
}
}
这里是文件输出:
Successfully copied the file. Starting unzip.
Extracted Hotel_All_Active 01-19-11.txt onto our server.
Renamed update file to content.txt.
The update file is ready to go. Now you can use the update functions.
的问题是,它不重命名文件。我也尝试过:
$this->zip->renameName(strval($this->extracted),'content.txt')
但是,这也打印出来,它重命名文件,但没有。我在这里做错了什么,或者是这个功能越野车?
谢谢!你是对的。 PHP.net文档没有很好地解释。 – Jarred 2011-01-20 05:30:28