467,888 Members | 1,592 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,888 developers. It's quick & easy.

Does anyone know what this file error means ?

100+
Hi,

I am running ZipArchive on a downloaded zipped file
and I am getting An Error No. 19.

My log gives this output:

-Saved as file: /home/guru54gt5/public_html/sys/a_xml_file.zip
-File size: 278528 bytes
Found: /home/guru54gt5/public_html/sys/a_xml_file.zip
Could not open /home/guru54gt5/public_html/sys/a_xml_file.zip
Error # 19
This is the script I am running:

Expand|Select|Wrap|Line Numbers
  1. if (!class_exists('ZipArchive')) {
  2.    write_log("Class ZipArchive not found\r\n");
  3.  
  4.    exit;
  5. } else {
  6.     $zip = new ZipArchive;
  7. }
  8.  
  9. if (!$file_zip) {
  10.     write_log("Could not find  $file_zip\r\n Error # $err\r\n");  
  11.     exit;
  12.         } 
  13. else {
  14.     write_log("Found: $file_zip\r\n");
  15.     }
  16.  
  17. if (($err = $zip->open($file_zip)) !== true) {
  18.     write_log("Could not open  $file_zip\r\n Error # $err\r\n");  
  19.     exit;
  20.         } 
  21. else {
  22.     write_log("File opened: $file_zip\r\n");
  23.     }
  24.  
This ZipArchive is working fine in a similar script that donsloads a different
file. Does anyone know what Error # 19 means and how
I can cure it ?


Thanks
Mar 1 '10 #1
  • viewed: 2400
Share:
9 Replies
Dormilich
Expert Mod 8TB
it means "Not a Zip Archive" (see Predefined Constants)
Mar 1 '10 #2
100+
Thanks Dormilich.

I looked up those "Predefined Constants" and I see a list of them.

Above the list is this:
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

ZipArchive uses class constants. There are three types of constants : Flags (prefixed with FL_), errors (prefixed with ER_) and mode (no prefix).
But I can not see where you identify that the file is "Not a Zip Archive" .

I manually unzipped the file to check it.

Actually, none of my three download-unzip scripts worked last night,
either I changed all three by mistake, or something in my php confiq has
gone wrong.

Would appreciate it if you can cast some more light on the problem

Thanks


.
Mar 1 '10 #3
Dormilich
Expert Mod 8TB
@jeddiki
the first user note/comment.
Mar 1 '10 #4
100+
OK found it.

(the notes were contracted and I didn't notice
the + sign before)

So I think there must be something wrong with my code
because the file that download to my server is
a zip file and I can unzip it manually. !

I will do a few tests ( don't want to be lazy ;) )
if I can not find the answer, then I will come back and
post my code ... maybe you will see the error!

Thanks again. :)



.
Mar 1 '10 #5
100+
Ok

I have to admit defeat on this :(

I did have it running OK up until Friday but something has changed.

Maybe it is to do with the file name.

I am downloading the clickbank marketplace
and trying to unzip it using cUrl and ZipArchive.

Here is my little script with all the logging.

Expand|Select|Wrap|Line Numbers
  1. $target_url = "http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip";
  2. $userAgent = 'EasyDL/3.xx';
  3. $file_zip = $file_dir."a_zip_clickbank.zip";
  4. $cef = "curl_err.txt"; 
  5. $ceh = fopen($cef, 'wb');
  6.  
  7. write_log("Target_url: $target_url\r\n");
  8.  
  9. // make the cURL request to $target_url
  10. $ch = curl_init();
  11. $fp = fopen("$file_zip", "wb");
  12.  
  13. if ($fp === FALSE ) { 
  14.   write_log("Problem opening $file_zip\r\n");
  15.     exit;
  16. }
  17.  
  18. curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
  19. curl_setopt($ch, CURLOPT_URL,$target_url);
  20. curl_setopt($ch, CURLOPT_FAILONERROR, true);
  21. curl_setopt($ch, CURLOPT_STDERR, $ceh);        
  22. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  23. curl_setopt($ch, CURLOPT_HEADER,0); 
  24. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  25. curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  26. curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
  27. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  28. curl_setopt($ch, CURLOPT_FILE, $fp);
  29.  
  30. $output = curl_exec($ch);
  31. $info = curl_getinfo($ch);
  32.  
  33. if ($output === FALSE || $info['http_code'] != 200) {
  34.   write_log("No cURL data returned for $target_url [". $info['http_code']. "]\r\n ");
  35.   if (curl_error($ch)) write_log($output."CURL error number: curl_errno($ch)\r\n CURL error: curl_error($ch)\r\n");
  36.     exit;
  37.   }
  38. else {
  39.   write_log("CURL completed successfully.\r\n");
  40.     }
  41.  
  42. curl_close($ch);
  43.  
  44. if(file_exists($file_zip)) {
  45.   $fsz = filesize($file_zip);
  46.   }
  47. else {
  48.     write_log("File: $file_zip does not exist \r\n");
  49.       exit;
  50.   }
  51.  
  52. write_log("Downloaded file: $target_url\r\n-Saved as file: $file_zip\r\n-File size: $fsz bytes \r\n");
  53.  
  54. // Un zip the file 
  55.  
  56. // After curl code:
  57. fclose($fp);
  58. fclose($ceh);
  59.  
  60. if (!class_exists('ZipArchive')) {
  61.    write_log("Class ZipArchive not found\r\n"); 
  62.    exit;
  63.      } 
  64. else {
  65.   $zip = new ZipArchive;
  66. }
  67.  
  68. if (!$file_zip) {
  69.     write_log("Could not find  $file_zip\r\n Error # $err\r\n");  
  70.     exit;
  71.         } 
  72. else {
  73.     write_log("Found: $file_zip\r\n");
  74.     }
  75.  
  76. if (($err = $zip->open($file_zip)) !== true) {
  77.     write_log("Could not open  $file_zip\r\n Error # $err\r\n");
  78.     exit;
  79.         }
  80. else {
  81.     write_log("File opened\r\n");
  82. }
  83.  
  84. if (!$zip->extractTo($file_dir)) {
  85.     write_log("Extraction error\r\n");
  86.         exit; 
  87.     }
  88.  
This is my log that gets written by the scrpt.

Target_url: http://www.clickbank.com/feeds/marke...eed_v1.xml.zip
CURL completed successfully.
Downloaded file: http://www.clickbank.com/feeds/marke...eed_v1.xml.zip
-Saved as file: /home/guru54gt5/public_html/sys/a_zip_clickbank.zip
-File size: 2764800 bytes
Found: /home/guru54gt5/public_html/sys/a_zip_clickbank.zip
Could not open /home/guru54gt5/public_html/sys/a_zip_clickbank.zip
Error # 19
The file a_zip_clickbank.zip shows up on my server
and if I ftp it to my desktop, I can unzip it.

I don't know why I amp getting the error, but I think i is something to do
with defining the file name: $file_zip = $file_dir."a_zip_clickbank.zip";

Any ideas where I have gone wrong ?

Thanks.




.
Mar 1 '10 #6
Dormilich
Expert Mod 8TB
@jeddiki
nope, it worked for me. $zip->open() returned true. (didn’t use cURL, though)

PHP 5.3.1 on Darwin Melchior 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
Mar 1 '10 #7
100+
So what can be the problem then ?

I really don't know what to try :(

Maybe I am missing a SET_UP on the cUrl ?
Mar 1 '10 #8
100+
It MUST be something to do with me NOT using the
original file name - I seem to remember that when it was working
I was opening "marketplace_feed_v1.xml.zip"
not my "a_zip_clickbank.zip"

But I don't know how I coded it.

These two lines should mean that the file goes to
the specified output file right ?

Expand|Select|Wrap|Line Numbers
  1. curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
  2. curl_setopt($ch, CURLOPT_FILE, $fp);
Hmm ....

nope , maybe I am confussing it with when I have succeeded in unzipping the
file, then I have to use what is unzipped namely: "marketplace_feed_v1.xml "

Oh my !


.
Mar 1 '10 #9
100+
Could this i statement be wrongly coded ?

Expand|Select|Wrap|Line Numbers
  1. if (($err = $zip->open($file_zip)) !== true) {
  2.     write_log("Could not open  $file_zip\r\n Error # $err\r\n");
  3.     exit;
  4.        }
  5. else {
  6.     write_log("File opened\r\n");
  7. }
Maybe I should use a simple:

Expand|Select|Wrap|Line Numbers
  1. if (!$zip->open($file_zip) ) {
  2.     write_log("Could not open  $file_zip\r\n Error # $err\r\n");
  3.     exit;
  4.        }
  5. else {
  6.     write_log("File opened\r\n");
  7. }
Could that be the problem ?


.
Mar 1 '10 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by lawrence | last post: by
7 posts views Thread by Kilian A. Foth | last post: by
13 posts views Thread by Jason Huang | last post: by
4 posts views Thread by Lightmage | last post: by
2 posts views Thread by Lambda | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.