ziparchive

PHP ZipArchive non-English filenames return funky filenames within archive

戏子无情 提交于 2019-11-27 22:52:26
问题 This code works properly to make the ZIP file with the wanted files, except the filenames in the archive, which are not in English (in this case they are Hebrew), have weird characters instead of the proper hebrew letters. <?php $filesfordown = $_POST['GEMin']; if(empty($filesfordown)) { echo "No files were seleceted for download."; } else { $zip_name = "RMW." . time() . ".zip"; $zip = new ZipArchive; $zip->open($zip_name, ZipArchive::CREATE); foreach ($filesfordown as $filefordown) { $zip-

PHPExcel_Writer_Exception with message “Could not close zip file php://output.”

我是研究僧i 提交于 2019-11-27 19:03:29
I'm using PHPExcel to export some data to user in an excel file. I would like the script to send the excel file to the user immediately after it's creation. Here is my test code: try{ /* Some test data */ $data = array( array(1, 10 , 2 ,), array(3, 'qqq', 'some string' ,), ); $objPHPExcel = new PHPExcel(); $objPHPExcel->setActiveSheetIndex(0); /* Fill the excel sheet with the data */ $rowI = 0; foreach($data as $row){ $colI = 0; foreach($row as $v){ $colChar = PHPExcel_Cell::stringFromColumnIndex($colI++); $cellId = $colChar.($rowI+1); $objPHPExcel->getActiveSheet()->SetCellValue($cellId, $v);

ZIP all files in directory and download generated .zip

假装没事ソ 提交于 2019-11-27 11:41:22
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)); header("Location: adcs.zip"); ?> How to gather all the files from "images/" folder, except

Fatal error: Class 'ZipArchive' not found in

时光总嘲笑我的痴心妄想 提交于 2019-11-27 00:45:18
I have a problem that I install 'Archive_Zip 0.1.1' on Linux server, but when I try to run the script to create the zip file it gives the fatal error Fatal error: Class ZipArchive not found in ... where I put the code $zip = new ZipArchive; var_dump($zip); $res = $zip->open($filename, ZipArchive::OVERWRITE); if ($res !== TRUE) { echo 'Error: Unable to create zip file'; exit; } if (is_file($src)) { $zip->addFile($src); } else { // echo "<br>" . dirname(__FILE__) . $src;//'/install1'; if (!is_dir($src)) { $zip->close(); @unlink($filename); echo 'Error: File not found'; exit; } recurse_zip($src,

PHPExcel_Writer_Exception with message “Could not close zip file php://output.”

拜拜、爱过 提交于 2019-11-26 22:45:45
问题 I'm using PHPExcel to export some data to user in an excel file. I would like the script to send the excel file to the user immediately after it's creation. Here is my test code: try{ /* Some test data */ $data = array( array(1, 10 , 2 ,), array(3, 'qqq', 'some string' ,), ); $objPHPExcel = new PHPExcel(); $objPHPExcel->setActiveSheetIndex(0); /* Fill the excel sheet with the data */ $rowI = 0; foreach($data as $row){ $colI = 0; foreach($row as $v){ $colChar = PHPExcel_Cell:

overwriting file in ziparchive

我怕爱的太早我们不能终老 提交于 2019-11-26 22:24:05
I have archive.zip with two files: hello.txt and world.txt I want to overwrite hello.txt file with new one with that code: import zipfile z = zipfile.ZipFile('archive.zip','a') z.write('hello.txt') z.close() but it won't overwrite file, somehow it creates another instance of hello.txt — take a look at winzip screenshot: Since there is no smth like zipfile.remove() , what's the best way to handle this problem? There's no way to do that with python zipfile module. You have to create a new zip file and recompress everything again from the first file, plus the new modified file. Below is some code

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

让人想犯罪 __ 提交于 2019-11-26 11:04:33
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(fileStream); } } If I run this code, the archive file itself is created but foo.txt isn't. However, if I

Fatal error: Class &#39;ZipArchive&#39; not found in

↘锁芯ラ 提交于 2019-11-26 09:28:47
问题 I have a problem that I install \'Archive_Zip 0.1.1\' on Linux server, but when I try to run the script to create the zip file it gives the fatal error Fatal error: Class ZipArchive not found in ... where I put the code $zip = new ZipArchive; var_dump($zip); $res = $zip->open($filename, ZipArchive::OVERWRITE); if ($res !== TRUE) { echo \'Error: Unable to create zip file\'; exit; } if (is_file($src)) { $zip->addFile($src); } else { // echo \"<br>\" . dirname(__FILE__) . $src;//\'/install1\';

ZipArchive creates invalid ZIP file

a 夏天 提交于 2019-11-26 05:34:53
问题 I am trying to create a new ZIP package from code with one entry and save the ZIP package to a file. I am trying to achive this with the System.IO.Compression.ZipArchive class. I am creating the ZIP package with the following code: using (MemoryStream zipStream = new MemoryStream()) { using (ZipArchive zip = new ZipArchive(zipStream, ZipArchiveMode.Create)) { var entry = zip.CreateEntry(\"test.txt\"); using (StreamWriter sw = new StreamWriter(entry.Open())) { sw.WriteLine( \"Etiam eros nunc,