php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48338 extractTo - unexpected results
Submitted: 2009-05-19 22:28 UTC Modified: 2009-05-19 23:24 UTC
From: bugreport at hotmail dot co dot uk Assigned:
Status: Not a bug Package: Zip Related
PHP Version: 5.2.9 OS: CENTOS 5.2 i686 xen on server
Private report: No CVE-ID: None
 [2009-05-19 22:28 UTC] bugreport at hotmail dot co dot uk
Description:
------------
I am trying to unpack a Zip file.  Permissions on both the Zip file and the destination directory (which is the same directory as the Zip file is in) are set to 0777.

Running extractTo (zlib 1.2.3 installed) using code from example 1 at http://uk2.php.net/manual/en/function.ziparchive-extractto.php
including
	$zip->extractTo('/path/...../');

results in no return to the browser (and the Zip file not being unpacked).

Changing the above to

	$directory = '/path/...../';
	$zip->extractTo('$directory');

results in " Warning: ZipArchive::extractTo() [ziparchive.extractto]: Permission denied in /path/....../script_file_name.php on line 12 "

Again the Zip file is not unpacked.

Reproduce code:
---------------
<?php

	$zip = new ZipArchive;

	if ($zip->open('/path/...../xyz.zip') === TRUE)
	{
		$zip->extractTo('/path/...../');
    $zip->close();
    echo 'ok';
	}
	else
	{
    echo 'failed';
	}
?>

Expected result:
----------------
Echo 'ok' (or 'failed')
Zip file unpacked

Actual result:
--------------
Nothing returned to the browser.
Zip file not unpacked.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-19 23:01 UTC] jani@php.net
Works fine when your permissions are correct. Make sure the user as 
which your webserver runs as has permissions to write and execute to 
that path.
 [2009-05-19 23:24 UTC] bugreport at hotmail dot co dot uk
Hi, thanks for your reply.

Just run some more tests, turned out to be a problem with the Zip files I was receiving.  These opened fine when downloaded and opened with Windows, but gave the results documented when opened on the server.  I've since tried opening Zip files from different sources on the server which open fine.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Aug 22 07:01:26 2019 UTC