1

**EDIT***

I've been having a hard time setting up the password to my files. I basically just want to protect the files that are going to be compressed into a zip file. So far, this is my code to zip the files.

I tried using system('zip -P password zipfile.zip file.extension'); but id doesn't seem to work.

*edited code

$files = array(
            'packages/download.xml',
            'packages/script_'.date("j.n.Y").'.xml',

        );

        $zip = new ZipArchive();
        $zip_name = "packages/test.package";
        if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){
            $error .= "* Sorry ZIP creation failed at this time";
        }

        foreach($files as $file){
            $zip->addFile($file);
        }
                    system('zip -P password zipfile.zip file.extension');
                   $zip->close();
user3026876
  • 31
  • 2
  • 10
  • I already saw and tried it. But it doesn't seem to work for me. I tried using this line - system('zip -P password zipfile.zip file.extension'); – user3026876 Jan 09 '14 at 05:42

1 Answers1

0

PHP builtin library does not support encryption.

You will have to call a binary executable or bind a non-standard library to do the job, which could be a problem depending on where your site is hosted.

kuroi neko
  • 8,479
  • 1
  • 19
  • 43
  • Could you help me? what should I use? As of now, I'm running my site in windows, but the main server will be in linux. Does gzip will do the trick? – user3026876 Jan 09 '14 at 05:51
  • Any zip program will do the trick, provided you have the right to execute it from within PHP. This is a matter of server configuration, so I can hardly be more specific. – kuroi neko Jan 09 '14 at 05:52
  • What should I do first? I'm sorry, I'm really lost with this one. – user3026876 Jan 09 '14 at 06:58