Sep 24

Password Protecting a Zip File Using PHP

Tag: Programming & InternetDustin @ 10:47 am

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\"");



Clicky Web Analytics