how to convert in zip folder using php script
Demo here
My this code demo you how to convert any file/files into .zip format using php code.
step 1/4 – Saveas index.php:

<script language=”javascript” type=”text/javascript”>
function jayjava1()
var str = document.form1.str.value;
str = str.split(“,”);
for(var i = 0; i<str.length; i++)
str[i] = str[i];
//each string is taken one by one in the string array



<form name=”form1″ method=”post” action=”<?php echo $_SERVER['PHP_SELF'] ?>” onsubmit=”return jayjava1(); “>
Enter file name that want to convert in pdf(If more then one file then comma seperated only):<br /><input type=”text” name=”str” size=”120″ value=”1.jpg,2.jpg,3.jpg,4.jpg,5.jpg,6.jpg,img.jpg,7450.pdf,OHHH_NO.wmv,Shankh.mp3″ />
<input type=”submit” name=”convertZip” value=”convertZip”>

step 2/4 -Saveas ziper.php:

header(“Content-type: application/zip”);
$tempNmae = time().”.zip”;
header(‘Content-Disposition: attachment; filename=”‘.$tempNmae.’”‘);
$source = “sourceFiles/”;
$name = htmlspecialchars($_REQUEST[name]);
$name = explode(“,”,$name);
$ziper = new zipfile();
foreach($name as $k)
//$zippingFiles= $source.$k.”,”;
$zippingFiles= $source.$k;
//$zippingFiles = substr($zippingFiles, 0, -1);//removing last coma

echo file_get_contents($tempNmae); //Write file in string format
unlink($tempNmae); //Delete the file

step 3/4 -Saveas zip.lib.php:
download here entire code

step 4/4 -Saveas sourceFiles (entire source files here to be zipped):
download here entire code

Share on Facebook