php zip file - add new_ziparchive?
I need to create a zzip file , i tried a script but i get an error message:
Warning: ZipArchive::addFile() [ziparchive.a开发者_如何学编程ddfile]: 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);
you'll need to use $_FILES["file"]["tmp_name"]
not $_FILES["file"]["name"]
精彩评论