how to set permission 777 to a zip file?

瘦欲@ 提交于 2019-12-25 02:18:33

问题


I am trying to zip files and I want to set the permission to chmod 777. But i don't know how/where I should write the chmod 777. Could anyone please help me? This is my code for zipping files.

$files = array(
            'download.xml',
            'script_.xml',

        );

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

        foreach($files as $file){
            $zip->addFile($file);
        }

        $zip->close();
        echo shell_exec("zip -P pass test.zip script.xml");

回答1:


add this to your code.

chmod("/to/your/zip/file", 777);

And for more informations read php manual for chmod




回答2:


It's possible you do not have the required permission to change file permissions. I would suggest contacting your hosting provider to have them change it for you. Generally, 777 is a very bad permission to have set on any file. See: https://webmasters.stackexchange.com/questions/18280/why-chmod-777-is-not-secure

If you do own the machine, run sudo chmod 777 filename.zip



来源:https://stackoverflow.com/questions/21249545/how-to-set-permission-777-to-a-zip-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!