php zip

Solutions on MaxInterview for php zip by the best coders in the world

showing results for - "php zip"
Elsa
08 Aug 2019
1<?php
2    $error = "";        //error holder
3    if(isset($_POST['createpdf'])){
4        $post = $_POST;     
5        $file_folder = "files/";    // folder to load files
6        if(extension_loaded('zip')){    // Checking ZIP extension is available
7            if(isset($post['files']) and count($post['files']) > 0){    // Checking files are selected
8                $zip = new ZipArchive();            // Load zip library 
9                $zip_name = time().".zip";          // Zip name
10                if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){       // Opening zip file to load files
11                    $error .=  "* Sorry ZIP creation failed at this time<br/>";
12                }
13                foreach($post['files'] as $file){               
14                    $zip->addFile($file_folder.$file);          // Adding files into zip
15                }
16                $zip->close();
17                if(file_exists($zip_name)){
18                    // push to download the zip
19                    header('Content-type: application/zip');
20                    header('Content-Disposition: attachment; filename="'.$zip_name.'"');
21                    readfile($zip_name);
22                    // remove zip file is exists in temp path
23                    unlink($zip_name);
24                }
25
26            }else
27                $error .= "* Please select file to zip <br/>";
28        }else
29            $error .= "* You dont have ZIP extension<br/>";
30    }
31?>
32<!DOCTYPE html>
33<html lang="en">
34<head>
35<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
36<title>Download As Zip</title>
37</head>
38<body>
39<center><h1>Create Zip</h1></center>
40<form name="zips" method="post">
41<?php if(!empty($error)) { ?>
42<p style=" border:#C10000 1px solid; background-color:#FFA8A8; color:#B00000;padding:8px; width:588px; margin:0 auto 10px;"><?php echo $error; ?></p>
43<?php } ?>
44<table width="600" border="1" align="center" cellpadding="10" cellspacing="0" style="border-collapse:collapse; border:#ccc 1px solid;">
45  <tr>
46    <td width="33" align="center">*</td>
47    <td width="117" align="center">File Type</td>
48    <td width="382">File Name</td>
49  </tr>
50  <tr>
51    <td align="center"><input type="checkbox" name="files[]" value="a.jpg" /></td>
52    <td align="center"><img src="files/image.png" title="Image" width="16" height="16" /></td>
53    <td>a.jpg</td>
54  </tr>
55  <tr>
56    <td align="center"><input type="checkbox" name="files[]" value="b.jpg" /></td>
57    <td align="center"><img src="files/image.png" title="Image" width="16" height="16" /></td>
58    <td>b.jpg</td>
59  </tr>
60  <tr>
61    <td align="center"><input type="checkbox" name="files[]" value="c.docx" /></td>
62    <td align="center"><img src="files/doc.png" title="Document" width="16" height="16" /></td>
63    <td>c.docx</td>
64  </tr>
65  <tr>
66    <td align="center"><input type="checkbox" name="files[]" value="d.pdf" /></td>
67    <td align="center"><img src="files/pdf.png" title="pdf" width="16" height="16" /></td>
68    <td>d.pdf</td>
69  </tr>
70  <tr>
71    <td colspan="3" align="center">
72        <input type="submit" name="createpdf" style="border:0px; background-color:#800040; color:#FFF; padding:10px; cursor:pointer; font-weight:bold; border-radius:5px;" value="Download as ZIP" /> 
73        <input type="reset" name="reset" style="border:0px; background-color:#D3D3D3; color:#000; font-weight:bold; padding:10px; cursor:pointer; border-radius:5px;" value="Reset" />
74    </td>
75    </tr>
76</table>
77
78</form>
79</body>
80</html>
Blue
03 Aug 2018
1#PHP 5.6: Use the --with-libzip=DIR configure option to use a system libzip installation. libzip version 0.11 is required, with 0.11.2 or later recommended.
2
3#PHP 7.3: Building against the bundled libzip is discouraged, but still possible by adding --without-libzip to the configuration.
4
5zip_close()	Closes a ZIP file archive
6zip_entry_close()	Closes a ZIP directory entry
7zip_entry_compressedsize()	Returns the compressed file size of a ZIP directory entry
8zip_entry_compressionmethod()	Returns the compression method of a ZIP directory entry
9zip_entry_filesize()	Returns the actual file size of a ZIP directory entry
10zip_entry_name()	Returns the name of a ZIP directory entry
11zip_entry_open()	Opens a directory entry in a ZIP file for reading
12zip_entry_read()	Reads from an open directory entry in the ZIP file
13zip_open()	Opens a ZIP file archive
14zip_read()	Reads the next file in a open ZIP file archive
queries leading to this page
php ext zipphp zip contentsphp ziparchive examplezip en php avec ziparchivecreate zip file in phpzip for phpphp ziparchive return zip filephp zip makehow to zip file in phpphp 24zip 3d new ziparchive 28 29 3bzip in phpgenereta zip phpphp zip archive and emailhow heavy is php zipziparchive 28 29php ziparchive tutorialphp zip file creationzip php file in phpphp module zipfile zip phpphp how to access zip filesphp zip filesphp zip installzipper phpdownload php zip php install zip extensionphp zip scriptcreate zip phpziparchive php downloadcreate a zip of files in phpphp ziparchive create zip filephp ziparchive sophp zip archivezip file function in phpziparchive enable phpphp new ziparchiveziparchive php 7php ziparchive opencreating zip in phpziparchive 2b php iniinstall php ziparchivezipstream php php download 24zipziparchive 28 29 phpphp zip file and downloadhow to archive in phpzip array phpwhp zipziparchive php tutophp put files into zipziparchive phpphp zip a filecreate zip file with phpzip a file in phpphp7 zip zip download in phparchive 3d 1 in phpphp zip directory and downloadphp new ziparchive 28 29create zip using phpphp zip zipphp zip module zip archieve in phpphp zipachrivecreate zip with phpziparchive in php iniphp zip filezip phpzipfile 28 29 phpphp zip arrayphp zip supporthow zip a file in phpzip formate phpphp add zip php zip stingdownload zip phpphp crete zipzip a php filezip file in php zip archive phpphp ziparchiveinstall php zip php ziphow to use ziparchive in phpzip system phpphp zip arrayszip lib for phpphp zip installmake zip with phpphp file zipperziparchive in phpphp zip for php 7 0zip download phpcreate zip fil in phpphp zip archive examplephp function to create zip filephp zip libraryhow to zip a file in phpwindows php zipphp how to make new zip filezip file php examplephp zipphp zip a directoryphp create zip file 24zipfile 3d new 5cphpzip 5czipfile 28 29 3bphp zip installphp windows zipphp ziparchive zip only zip filesphp test ziparchive using cliscaricarre file zip phpphp generate zip filephp ziparchive installphp zip files and php update a file inside zipmake zip file in phphow to zip files in phpstream a zip file for download in phpziparchive php parametersziparchive php 7 2zip files phpziparchive php examplephp adding lots of big files to zipphp how to stream a zip filephp zip packagephp zip examplezip file phpphp ziparchive zip all zip filesphp how to make zipnew ziparchive phpinstall zip phpphp zip functionphp 7 zip archivecreate zip in phpphp zip extemntiombulz zip using phpphp create zipuse ziparchive phpphp zip classlatest php zip filephp zip stringphp download zipphp zip download php zip