christopher's avatar

Set Password on Uploaded Files

I currently building a little File Upload Script.

Now i want to give the User the option to protect his files with a Password. My thought was, to take the uploaded file, zip it, and give the .zip file a password.

I took a look at the ZIP Storage Provider from thephpleague. But i didnt found an Option to zip files? Otherwise there is a cool Package available which comes with this features: https://github.com/comodojo/zip

But for both packages i did not found an option how to protect a generated zip file with a Password. Does somebody has maybe a little tip for me how to protect a .zip file with a password? :)

There is the ziparchive.setpassword.php function, but as far as i understand this, its only to open a protected .zip on the Server right?

0 likes
3 replies
cbj4074's avatar

I'm not familiar with any of those libraries, in particular, but why not simply use 7-zip to create the ZIP archive with encryption and a password?

Provided you have the ability to install 7-zip, or request that it be installed for you, it should be as simple as calling the command-line executable and passing it appropriate arguments.

In 7-zip, the -p switch is used to add a password to the archive.

You can find examples of the specific syntax about halfway down this page (search for the word "secret"):

http://www.dotnetperls.com/7-zip-examples

SaeedPrez's avatar

So anyone should be able to download the files without a password? But they need to have a password to unpack the files?

Please or to participate in this conversation.