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: -
if (!class_exists('ZipArchive')) {
-
write_log("Class ZipArchive not found\r\n");
-
-
exit;
-
} else {
-
$zip = new ZipArchive;
-
}
-
-
if (!$file_zip) {
-
write_log("Could not find $file_zip\r\n Error # $err\r\n");
-
exit;
-
}
-
else {
-
write_log("Found: $file_zip\r\n");
-
}
-
-
if (($err = $zip->open($file_zip)) !== true) {
-
write_log("Could not open $file_zip\r\n Error # $err\r\n");
-
exit;
-
}
-
else {
-
write_log("File opened: $file_zip\r\n");
-
}
-
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
9 3188 Dormilich 8,658
Recognized Expert Moderator Expert
it means "Not a Zip Archive" (see Predefined Constants)
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
.
Dormilich 8,658
Recognized Expert Moderator Expert @jeddiki
the first user note/comment.
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. :)
.
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. -
$target_url = "http://www.clickbank.com/feeds/marketplace_feed_v1.xml.zip";
-
$userAgent = 'EasyDL/3.xx';
-
$file_zip = $file_dir."a_zip_clickbank.zip";
-
$cef = "curl_err.txt";
-
$ceh = fopen($cef, 'wb');
-
-
write_log("Target_url: $target_url\r\n");
-
-
// make the cURL request to $target_url
-
$ch = curl_init();
-
$fp = fopen("$file_zip", "wb");
-
-
if ($fp === FALSE ) {
-
write_log("Problem opening $file_zip\r\n");
-
exit;
-
}
-
-
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
-
curl_setopt($ch, CURLOPT_URL,$target_url);
-
curl_setopt($ch, CURLOPT_FAILONERROR, true);
-
curl_setopt($ch, CURLOPT_STDERR, $ceh);
-
curl_setopt($ch, CURLOPT_VERBOSE, 1);
-
curl_setopt($ch, CURLOPT_HEADER,0);
-
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
-
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
-
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
-
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
-
curl_setopt($ch, CURLOPT_FILE, $fp);
-
-
$output = curl_exec($ch);
-
$info = curl_getinfo($ch);
-
-
if ($output === FALSE || $info['http_code'] != 200) {
-
write_log("No cURL data returned for $target_url [". $info['http_code']. "]\r\n ");
-
if (curl_error($ch)) write_log($output."CURL error number: curl_errno($ch)\r\n CURL error: curl_error($ch)\r\n");
-
exit;
-
}
-
else {
-
write_log("CURL completed successfully.\r\n");
-
}
-
-
curl_close($ch);
-
-
if(file_exists($file_zip)) {
-
$fsz = filesize($file_zip);
-
}
-
else {
-
write_log("File: $file_zip does not exist \r\n");
-
exit;
-
}
-
-
write_log("Downloaded file: $target_url\r\n-Saved as file: $file_zip\r\n-File size: $fsz bytes \r\n");
-
-
// Un zip the file
-
-
// After curl code:
-
fclose($fp);
-
fclose($ceh);
-
-
if (!class_exists('ZipArchive')) {
-
write_log("Class ZipArchive not found\r\n");
-
exit;
-
}
-
else {
-
$zip = new ZipArchive;
-
}
-
-
if (!$file_zip) {
-
write_log("Could not find $file_zip\r\n Error # $err\r\n");
-
exit;
-
}
-
else {
-
write_log("Found: $file_zip\r\n");
-
}
-
-
if (($err = $zip->open($file_zip)) !== true) {
-
write_log("Could not open $file_zip\r\n Error # $err\r\n");
-
exit;
-
}
-
else {
-
write_log("File opened\r\n");
-
}
-
-
if (!$zip->extractTo($file_dir)) {
-
write_log("Extraction error\r\n");
-
exit;
-
}
-
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.
.
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
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 ?
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 ? - curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
-
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 !
.
Could this i statement be wrongly coded ? - if (($err = $zip->open($file_zip)) !== true) {
-
write_log("Could not open $file_zip\r\n Error # $err\r\n");
-
exit;
-
}
-
else {
-
write_log("File opened\r\n");
-
}
Maybe I should use a simple: - if (!$zip->open($file_zip) ) {
-
write_log("Could not open $file_zip\r\n Error # $err\r\n");
-
exit;
-
}
-
else {
-
write_log("File opened\r\n");
-
}
Could that be the problem ?
.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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();...
|
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
|
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>
|
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...
|
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
| |
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...
|
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...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - Why does parseInt('09') give an error?
-----------------------------------------------------------------------
...
|
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. ...
|
by: Lambda |
last post by:
The code is simple:
// Token.h
#ifndef TOKEN_H
#define TOKEN_H
#include <vector>
#include <string>
class Token
|
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...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |