PHP: Apply Chmod during Unarchiving

This is what I still have. I need to be able to apply 0666 to all files in the archive. Can't I do this since I export? What is the sample code for changing chmod during disassembly or after disassembly?

$zip = new ZipArchive;
if ($zip->open('upload/'. $username . $file_ext) === TRUE) {
$zip->extractTo('dir/' . $username);
$zip->close();
} else {
echo 'failed';
}

Thanks for the help! Brandon

+3
source share
1 answer

Setting 0666in directories may not be what you want; -)

Linux 0777 0666 , , umask, . umask 0022, , 0644; .

, umask 0, , , , .

umask(0);
$zip = new ZipArchive;
if ($zip->open('upload/'. $username . $file_ext) === TRUE) {
    $zip->extractTo('dir/' . $username);
    $zip->close();
} else {
    echo 'failed';
}
+3

All Articles