web 2.0

How to use PHP & Upload Multiple file and Zip file

How to use PHP & Upload Multiple file and Zip file This is Learn / tutorial php programming how to usingĀ  PHP multiple upload and Zip file.

ShotDev Focus:
- PHP & Multiple upload and Zip file.

Example

php_zip_multiple1.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form action="php_zip_multiple2.php" method="post" enctype="multipart/form-data" name="frmMain">
<table width="343" border="1">
<tr>
<td>Zip Name</td>
<td><input name="txtZipName" type="text"></td>
</tr>
<tr>
<td>Files</td>
<td>
<input name="fileUpload[]" type="file"><br>
<input name="fileUpload[]" type="file"><br>
<input name="fileUpload[]" type="file"><br>
<input name="fileUpload[]" type="file"><br>
<input name="fileUpload[]" type="file"><br>
<input name="fileUpload[]" type="file"><br></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Upload"></td>
</tr>
</table>
</form>
</body>
</html>

php_zip_multiple2.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
$ZipName = "myfile/".$_POST["txtZipName"];
require_once("dZip.inc.php"); // include Class
$zip = new dZip($ZipName); // New Class

//*** Zip Files ***/
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
{
if($_FILES["fileUpload"]["name"][$i] != "")
{
$zip->addFile($_FILES["fileUpload"]["tmp_name"][$i],$_FILES["fileUpload"]["name"][$i]); // Source,Destination
}
}

$zip->save();
echo "Zip Successful Click <a href=$ZipName>here</a> to Download";
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_zip_multiple1.php

Screenshot

PHP Upload Multiple file and Zip file

PHP Upload Multiple file and Zip file
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.