I need to create a zzip file , i tried a script but i get an error message:
Warning: ZipArchive::addFile() [ziparchive.addfile]: Invalid or unitialized Zip object
this is my script:
<?php
$path = "./downloads/";
$file = $_FILES["file"]["name"];
$zip=new ZipArchive;
$zip->addFile('./downloads/', $_FILES["file"]["name"]);
?>
Look at the example here .
You have to call the open
method:
$zip->open("/path/to/filename.ext", ZIPARCHIVE::CREATE);
Or call the constructor in a different fashion:
$zip = new ZipArchive("/path/to/filename.ext", ZIPARCHIVE::CREATE);
您需要使用$_FILES["file"]["tmp_name"]
而不是$_FILES["file"]["name"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.