Advertisement

05.11.2008 at 04:10AM PDT, ID: 23392582
[x]
Attachment Details

Problem with zip_open() returning integer instead of resource

Asked by shakoush2001 in PHP Scripting Language, Web Languages/Standards, Scripting Languages

Hi
I am trying to extract a zip archive located on the server. The archive is at http://79.170.88.19/~gaf3//newdir/subdir/Archive.zip it is readable. And I compiled zip support into php

Zip       enabled
Extension Version       $Id: php_zip.c,v 1.1.2.38 2007/08/06 22:02:32 bjori Exp $
Zip version       2.0.0
Libzip version       0.7.1

My Code can be found below, the error I am getting is

Warning: zip_read() expects parameter 1 to be resource, integer given in /home/gaf3/domains/bla3.com/public_html/autoinstall.php on line 67

Warning: zip_close() expects parameter 1 to be resource, integer given in /home/gaf3/domains/bla3.com/public_html/autoinstall.php on line 76

As you can see I used $file = getcwd() . '/Archive.zip'; to get the file location
$file is /home/gaf3/domains/bla3.com/public_html/newdir/subdir/Archive.zip
I also tried $file=./Archive and $file=/public_html/newdir/subdir/Archive.zip

I DO know that it is most probably a file location error..but I can point my finger on it. Linux server used.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
$file = getcwd() . '/Archive.zip';
echo $file;
$zip = zip_open($file);
echo $zip;
if ($zip) {
  while ($zip_entry = zip_read($zip)) {
   $fp = fopen(zip_entry_name($zip_entry), "w");
  if (zip_entry_open($zip, $zip_entry, "r")) {
   $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
   fwrite($fp,"$buf");
  zip_entry_close($zip_entry);
  fclose($fp);
  }
  }
 zip_close($zip);
}
else
echo "not valid resource";
 
 
[+][-]05.11.2008 at 06:29AM PDT, ID: 21542409

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Web Languages/Standards, Scripting Languages
Sign Up Now!
Solution Provided By: ahoffmann
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.11.2008 at 05:21PM PDT, ID: 21544036

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906