简体   繁体   中英

PHP ZipArchive 600 file permission

PHP ZipArchive chmod 600 the problem of access to the file.

A temporary archive is created, with rights 600 (-rw-------) because of which it can not work with it.

Here's what the temporary archive looks like: archive_19-05-2020_18-33-51.zip.GIKCH2

Locally, everything is archived and the tempo file I do not even see in the process. When transferring to the server (linux), there is a problem with access to the archive.

Archiving Code Standard.

$zip = new \ZipArchive();
if ($zip->open('upload/archive_19-05-2020_18-33-51.zip', \ZipArchive::CREATE) !== TRUE) {
    throw new \Exception('Cannot create a zip file');
}
$zip->addFile('upload/file.txt', 'file.txt'); 
$zip->close();

When generating other files of the same csv, the file gets 644 permissions and you can safely work with it.

I can't understand what the problem is, why the archive is created with limited rights, although locally on (windows) everything works without problems.

The problem was that the php version is low (5.4) on the server i using. I upgraded php version for 5.6 and problem resolved. Thanks you all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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