note 78140 added to function.zip-read

From: Date: Sat, 29 Sep 2007 20:29:29 +0000
Subject: note 78140 added to function.zip-read
Groups: php.notes 
Request: Send a blank email to php-notes+get-130933@lists.php.net to get a copy of this message
If you get an error like this: Warning: zip_read() expects parameter 1 to be resource, integer given in xxxxxx on line x It's because zip_open() failed to open the file and returned an error code instead of a resource. It took me a while to figure out why it failed to open the file, until I tried to use the FULL path to the file. <?php // Even if the file exists, zip_open() will return an error code. $file = 'file.zip'; $zip = zip_open($file); // The workaround: $file = getcwd() . '/file.zip'; // Or: $file = 'C:\\path\\to\\file.zip'; ?> This worked for me on Windows at least. I'm not sure about other platforms. ---- Server IP: 64.71.164.2 Probable Submitter: 83.61.28.137 ---- Manual Page -- http://www.php.net/manual/en/function.zip-read.php Edit -- https://master.php.net/note/edit/78140 Del: integrated -- https://master.php.net/note/delete/78140/integrated Del: useless -- https://master.php.net/note/delete/78140/useless Del: bad code -- https://master.php.net/note/delete/78140/bad+code Del: spam -- https://master.php.net/note/delete/78140/spam Del: non-english -- https://master.php.net/note/delete/78140/non-english Del: in docs -- https://master.php.net/note/delete/78140/in+docs Del: other reasons-- https://master.php.net/note/delete/78140 Reject -- https://master.php.net/note/reject/78140 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130933) next »