Password Protecting a Zip File Using PHP

I needed a way to add a password to zip files I was creating in PHP, but it seems support for that is lacking. So I resorted to using Info-ZIP. This particular site I was running PHP on a Windows IIS server. Info-ZIP is free and supported on multiple platforms. I downloaded the Windows binary file and put zip.exe in my C:\WINDOWS folder. I then had to give the Internet User Execute permission on C:\WINDOWS\System32\cmd.exe in order for me to call the system() function in php.

Then I wrote a quick test script that seemed to work:

<?php
$filename = "filename.zip";
$pdf = "document.pdf";
echo system("zip -P 1234 -j $filename \"$pdf\"");

Related posts:

  1. Simple PHP Pluralize I often find myself writing a if statement when I...
  2. Django & Djson… er, JSON I must admin this is my first attempt at even...

Related posts brought to you by Yet Another Related Posts Plugin.

September 24, 2007   Posted in: Programming & Internet

One Response

  1. Vb Reader - August 27, 2009

    PHP too having some good stuffs as well. I worked for 7 months few years before. Despite i did not have good editor and debugging as Visual Studio. i liked its simplicity

Comments are closed for this entry.