简体   繁体   English

如何将权限777设置为一个zip文件?

[英]how to set permission 777 to a zip file?

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? 我正在尝试压缩文件,我想将权限设置为chmod777。但是我不知道应该如何/在何处编写chmod777。有人可以帮助我吗? 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");

add this to your code. 将此添加到您的代码。

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

And for more informations read php manual for chmod 有关更多信息,请阅读chmod的php手册

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. 通常,对任何文件进行设置都是非常不好的777许可。 See: https://webmasters.stackexchange.com/questions/18280/why-chmod-777-is-not-secure 参见: https : //webmasters.stackexchange.com/questions/18280/why-chmod-777-is-not-secure

If you do own the machine, run sudo chmod 777 filename.zip 如果您拥有计算机,请运行sudo chmod 777 filename.zip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM