在PHP中将文件压缩为ZIP时出现问题


Problems trying to compress files to ZIP in PHP

我有一段代码,试图将多个文件压缩到一个zip中。在PHP和MySQL的帮助下,我将链接保存在MySQL表上。问题是没有创建zip文件。这是代码:

<?php 

mysql_select_db("assignments",$conectar);  
    $result = mysql_query("SELECT * FROM pedimento"); 
<?php 
$enzipado = new ZipArchive(); 
if ($enzipado->open("activos.zip", ZIPARCHIVE::CREATE )!==TRUE) { 
    exit("No se pudo abrir el archivo'n"); 
} 
while($row = mysql_fetch_array($result)) {  
$enzipado->addFile($row['DepAduanero']); 
    }; 
$enzipado->close(); 
?> 
<a href="activos.zip">Descargar</a>

在使用文件之前,始终建议检查文件是否存在。所以使用file_exists()

http://php.net/manual/en/function.file-exists.php

或者您的查询没有返回任何行。o