Я извлекаю zip-файл в PHP и пытаюсь переименовать его в 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