473,503 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does anyone know what this file error means ?

290 Contributor
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
9 3188
Dormilich
8,658 Recognized Expert Moderator Expert
it means "Not a Zip Archive" (see Predefined Constants)
Mar 1 '10 #2
jeddiki
290 Contributor
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
8,658 Recognized Expert Moderator Expert
@jeddiki
the first user note/comment.
Mar 1 '10 #4
jeddiki
290 Contributor
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
jeddiki
290 Contributor
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
8,658 Recognized Expert Moderator Expert
@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
jeddiki
290 Contributor
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
jeddiki
290 Contributor
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
jeddiki
290 Contributor
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

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

Similar topics

7
7800
by: lawrence | last post by:
Suppose I create dynamic web pages with 3 functions (which call other functions to make everything happen, but these 3 you might think of as being the top layer): registerSessions();...
14
5834
by: Larry Woods | last post by:
I need to execute a Windows script (wscript/cscript) from an ASP page for some administrative functions. Anyone doing this? If so, how? TIA, Larry Woods
21
1777
by: Jim | last post by:
Hi I am a newbie to asp and i built this test program: <HTML> <HEAD><TITLE>Test</TITLE></HEAD> <BODY> the time is <% = Time %> </BODY> </HTML>
7
7500
by: Kilian A. Foth | last post by:
I just found this amazing video puzzle game written with the pygame library, which promises to be infinite fun - but I can't get it to decode any video file I own, except the game's own example...
13
4997
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
1
1297
by: news.microsoft.com | last post by:
Hi, I've just finished developing an web site locally (ASP 1.1) which works fine. Now that I have posted it to our server (which has 1.0 and 1.1 installed) I get the following error message when...
3
4384
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
25
9540
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does parseInt('09') give an error? ----------------------------------------------------------------------- ...
4
5334
by: Lightmage | last post by:
Hello all, I am using C++ to convert a certain file into an XML file. During the conversion the program does some arithmetic operations on the information that is then outputted in xml format. ...
2
13035
by: Lambda | last post by:
The code is simple: // Token.h #ifndef TOKEN_H #define TOKEN_H #include <vector> #include <string> class Token
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.