Learning & Integrating web technology and code help directory

How to use PHP & Upload and Zip file

No comments
How to use PHP & Upload and Zip file This is Learn / tutorial php programming how to using  PHP upload and Zip file.
ShotDev Focus:
- PHP & Upload and Zip file.
Example
php_upload_zip1.php
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <form action="php_upload_zip2.php" method="post" enctype="multipart/form-data" name="frmMain">  
  7. <table width="343" border="1">  
  8. <tr>  
  9. <td>Zip Name</td>  
  10. <td><input name="txtZipName" type="text"></td>  
  11. </tr>  
  12. <tr>  
  13. <td>Files</td>  
  14. <td>  
  15. <input name="fileUpload1" type="file"><br>  
  16. <input name="fileUpload2" type="file"></td>  
  17. </tr>  
  18. <tr>  
  19. <td>&nbsp;</td>  
  20. <td><input type="submit" name="Submit" value="Upload"></td>  
  21. </tr>  
  22. </table>  
  23. </form>  
  24. </body>  
  25. </html>  
php_upload_zip2.php
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?  
  7. $ZipName = "myfile/".$_POST["txtZipName"];  
  8. require_once("dZip.inc.php"); // include Class  
  9. $zip = new dZip($ZipName); // New Class  
  10.   
  11. //*** Files 1 ***/  
  12. if($_FILES["fileUpload1"]["name"] != "")  
  13. {  
  14. $zip->addFile($_FILES["fileUpload1"]["tmp_name"],$_FILES["fileUpload1"]["name"]); // Source,Destination  
  15. }  
  16.   
  17. //*** Files 2 ***/  
  18. if($_FILES["fileUpload2"]["name"] != "")  
  19. {  
  20. $zip->addFile($_FILES["fileUpload2"]["tmp_name"],$_FILES["fileUpload2"]["name"]); // Source,Destination  
  21. }  
  22.   
  23. $zip->save();  
  24. echo "Zip Successful Click <a href=$ZipName>here</a> to Download";  
  25. ?>  
  26. </body>  
  27. </html>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP Upload and Zip file
PHP Upload and Zip file

No comments :

Post a Comment