ziparchive

using zipArchive addFile() will not add image to zip

荒凉一梦 提交于 2019-12-18 20:51:25
问题 I've been at this for a while. This actually worked one time, then never again. it simply does not create the zip file. The file does exist. $zip = new ZipArchive(); $filename = "./test" . time() .".zip"; if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit("cannot open <$filename>\n"); } $thisdir = "$_SERVER[DOCUMENT_ROOT]/zip"; $zip->addFile($thisdir . "/trash-icon.png", "/gabage.png"); echo "numfiles: " . $zip->numFiles . "\n"; echo "status:" . $zip->status . "\n"; $zip->close();

Create a zip file using PHP class ZipArchive without writing the file to disk?

北慕城南 提交于 2019-12-17 18:05:52
问题 I would like to create a zip file in memory using a ZipArchive (or a native PHP class) and read the content of the file back to the client. Is this possible? If so, how? The files that I want to zip in this application are a maximum of 15 MB total. I think we should be in good shape memory-wise. 回答1: Take a look at the following library, it allows creating zip files and returning them as a stream: PHPClasses.org. 回答2: Try ZipStream (link to GitHub repo, also supports install via Composer).

ZIP all files in directory and download generated .zip

爱⌒轻易说出口 提交于 2019-12-17 10:27:13
问题 Well, first of all, this is my folder structure: images/ image1.png image11.png image111.png image223.png generate_zip.php And this is mine generate_zip.php: <?php $files = array($listfiles); $zipname = 'adcs.zip'; $zip = new ZipArchive; $zip->open($zipname, ZipArchive::CREATE); foreach ($files as $file) { $zip->addFile($file); } $zip->close(); header('Content-Type: application/zip'); header("Content-Disposition: attachment; filename='adcs.zip'"); header('Content-Length: ' . filesize($zipname

Creating a ZIP Archive in Memory Using System.IO.Compression

我的未来我决定 提交于 2019-12-17 02:04:07
问题 I'm trying to create a ZIP archive with a simple demo text file using a MemoryStream as follows: using (var memoryStream = new MemoryStream()) using (var archive = new ZipArchive(memoryStream , ZipArchiveMode.Create)) { var demoFile = archive.CreateEntry("foo.txt"); using (var entryStream = demoFile.Open()) using (var streamWriter = new StreamWriter(entryStream)) { streamWriter.Write("Bar!"); } using (var fileStream = new FileStream(@"C:\Temp\test.zip", FileMode.Create)) { stream.CopyTo

How to get PHP ZipArchive to work with variable

北战南征 提交于 2019-12-13 08:35:48
问题 I've been banging my head for a day or two now. The http://php.net/manual/en/ziparchive.extractto.php is pretty straight forward. The problem I have been having is trying to get the $zip->open('myFile.zip'); to accept a variable. $zip->open($myFile); I have noticed that in all the examples on the message board and even in the PHP site. The name of the zip file is hard coded in. I have seen one example of a variable being used but I can't get it to work. $path = 'zipfile.zip' $zip = new

Problems trying to add the libz.1.2.3.dylib to my ipad project

江枫思渺然 提交于 2019-12-13 03:41:16
问题 First of all, i'm now on this site so really sorry if i'm commiting some error posting this question.I'm trying to use the zipArchive class to manage zip files in an ipad project. What steps will reproduce the problem? Create a project. Add the ZipArchive folder with their files. Add the libz.1.2.3.dylib What is the expected output? What do you see instead? I have all the code (about ziparchive) commented, so i only have the #import #import "ZipArchive/ZipArchive.h" in my viewcontroller, and

What encoding does ZipArchive use to store file names inside the created archive?

孤街醉人 提交于 2019-12-12 10:48:08
问题 I'm using the php ZipArchive class in order to generate a zip archive. I use the second parameter of the addFile method in order to set the name of the file in the archive (since the real file on disk has a different name). Some of the names must contain french accents (such as é). When I download the archive, the accents aren't correctly displayed in the file name. What encoding should I use for the file names ? (the application uses UTF-8) 回答1: It is php bug #53948, see official bug report.

Create ziparchive native c# out of memory memorystream

三世轮回 提交于 2019-12-12 06:23:37
问题 I am using the build in feature to make a zip system.io.compression.ziparchive https://msdn.microsoft.com/en-us/library/system.io.compression.ziparchive.getentry%28v=vs.110%29.aspx and got: An exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll but was not handled in user code I have read this: ZipArchive creates invalid ZIP file and this is some of my code in an *.ashx file (webforms): Dictionary<string, string> csvs = new Dictionary<string, string>(); using (var

How to create a ZIP file using PHP and ZipArchive without sending it to the browser?

£可爱£侵袭症+ 提交于 2019-12-12 05:08:21
问题 My PHP/MySQL web application has a function that combines a set of images for each user into a single PDF using ImageMagick. Each PDF is then placed into a ZIP file. Each image can be up to 5 MB in size. My problem is that the browser times out before the user can download the document. Any ideas on how to best do this? I was thinking I could create the ZIP file without sending it to the browser (i.e. remove the "headers" at the end of my code) and then email a link to the file; however, it

Zip files in a folder and give the archive folder's name

淺唱寂寞╮ 提交于 2019-12-12 04:43:34
问题 I'm very new to php and I just made my first script, which is working fine, but is missing a final touch. The script zips all files in the folder containing the php and creates a downloadable archive. Here's the code <?php $zipname = 'test.zip'; $zip = new ZipArchive; $zip->open('D://mypath//zip//$zipname', ZipArchive::CREATE); if ($dir_handle = opendir('./')) { while (false !== ($entry = readdir($dir_handle))) { if ($entry != "." && $entry != ".." && !strstr($entry,'.php') && !strstr($entry,