10

I created an application, which using method extractTo() in class ZipArchive (standard in php) and I tested it on my localhost apache server on Windows 7 without any problem. But after I tried it on some unix production server, it just throws

Warning: ZipArchive::extractTo(): Permission denied in /path/to/file.php on line 27

I even set chmod on 0777 for every folder which is used by application, but it doesn't help.

Do you have any idea what's wrong?

1
  • 2
    The script needs to be able to access each parent folder recursively aswell, that doesn't mean 777, more 644. Sep 16, 2012 at 11:46

2 Answers 2

16

For linux / macosx user, change

$zip->extractTo('/Directory/');

To

$zip->extractTo('Directory/');

Can help too.

2
  • thank you for sharing this answer - it immediately fixed my issue running ZipArchive from the Linux terminal Oct 22, 2020 at 12:16
  • Thanks so much, would've never guessed this! Feb 16, 2022 at 13:00
5

Check if the user running Apache (sometimes a user "www-data") has access to the zip file in question.

Also try changing the owner of the file to the user running Apache (check top for the user).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.