开发者

php zip file - add new_ziparchive?

开发者 https://www.devze.com 2023-01-12 15:57 出处:网络
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

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"]

0

精彩评论

暂无评论...
验证码 换一张
取 消