473,225 Members | 1,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Does anyone know what this file error means ?

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

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

Similar topics

7
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
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
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
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
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
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
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
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does parseInt('09') give an error? ----------------------------------------------------------------------- ...
4
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
by: Lambda | last post by:
The code is simple: // Token.h #ifndef TOKEN_H #define TOKEN_H #include <vector> #include <string> class Token
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.