ZIP and password protect any file with simple script using PHP

Padlock - Security Image from Prolific Futility

“Rusty Padlock” artwork used with permission from ProlificFutility.com

You may need to password protect a file before sending it to someone.  Yes, there are Windows utilities, some free, that do this but I found this script works surprisingly well as long as “zip” is installed on your server. Just simply save the following file below to your website then upload the file you want to password protect. Be sure to rename “file.txt” in the below example to the name of the file you want to password protect and rename the “file.zip” to the name you want it output as then execute this script in the browser.  All you should have to do is download the ZIP archive version of this file.

When you download the file, you should be prompted with a password before opening.

– Aaron Belchamber

Aaron Belchamber has written 243 articles

Leave a Reply

Your email address will not be published. Required fields are marked *