zip - Unzip php files -



zip - Unzip php files -

i'm trying extract zip file witch contains php files.

taking illustration zip name 'test.zip' , inside, zip.php file code:

<?php class php{ } ?>

i've tried 2 differents snippets extract zipe file:

$zip = zip_open ( 'test.zip' ); while($file = zip_read($zip)){ $archivo = (zip_entry_name($file)); zip_entry_open($zip, $file); $contenido = zip_entry_read($file); $fopen = fopen($archivo,'w+'); fwrite($fopen, $contenido); } <?php $zip = new ziparchive; $res = $zip->open('test.zip'); if ($res === true) { $zip->extractto('./'); $zip->close(); echo 'ok!'; } else { echo 'ko!'; } ?>

but in both cases, result same:

<?php class phpclass{ function clase(){ } } ?>

the file extracted twice longer, , has twice of empty breaklines original.

is there anyway extract identical re-create of files contained in zip file?

please replace this:

$fopen = fopen($archivo,'w+');

... this:

$fopen = fopen($archivo,'w+b');

the b flag stands "binary" , disables line feed conversion. flags described in fopen() manual page.

php zip extract

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -