/    Sign up×
Community /Pin to ProfileBookmark

Zip file that script PHP can not unzip?

Hi,

I´m having problems to unzip a file, I tried 2 routine, but I have no success. Could anybody help me? The routine unzip some files, but the one that I want no.
The routines:

[CODE]$zip = new ZipArchive;
if ($zip->open($nome_file) === TRUE) {
$zip->extractTo(“./upload”);
$zip->close();
echo “ok”;
} else {
echo “failed”;
}
[/CODE]

OR

[CODE]$zip = zip_open($nome_file);
if($zip){
while ($zip_entry = zip_read($zip)) {
zip_entry_open($zip, $zip_entry);
if (substr(zip_entry_name($zip_entry), -1) == ‘/’) {
$zdir = substr(zip_entry_name($zip_entry), 0, -1);
if (file_exists($zdir)) {
trigger_error(‘Directory “<b>’ . $zdir . ‘</b>” exists’, E_USER_ERROR);
return false;
}
mkdir($zdir);
}
else {
$name = zip_entry_name($zip_entry);
chdir(‘upload’);
if (file_exists($name)) {
trigger_error(‘File “<b>’ . $name . ‘</b>” exists’, E_USER_ERROR);
return false;
}
$fopen = fopen($name, “w”);
fwrite($fopen, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)), zip_entry_filesize($zip_entry));
}
zip_entry_close($zip_entry);
}
zip_close($zip);
return true;
}
else{
echo “Faliled to open”;
}
[/CODE]

Note: When I unzip using some program like Winrar and compress again with this program, the file is unziped. And I tried to use this site: [url]http://www.wobzip.org/index.php[/url] , at this site, my file is uncompress perfectly, so there is a way, but I don’t know how and if they have used PHP!

Thank you,

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @S4ti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...