plutomed Posted February 17, 2007 Share Posted February 17, 2007 Ive looked allover google but i cant find how to extract zip files using php is it posible?? Link to comment https://forums.phpfreaks.com/topic/38883-solved-zip/ Share on other sites More sharing options...
redarrow Posted February 17, 2007 Share Posted February 17, 2007 Read this carefully ok. http://uk2.php.net/zip Link to comment https://forums.phpfreaks.com/topic/38883-solved-zip/#findComment-186986 Share on other sites More sharing options...
plutomed Posted February 17, 2007 Author Share Posted February 17, 2007 Read this carefully ok. http://uk2.php.net/zip can you tell me if can use those REMOVED WHOLE LINK theres my phpinfo() Link to comment https://forums.phpfreaks.com/topic/38883-solved-zip/#findComment-186990 Share on other sites More sharing options...
redarrow Posted February 17, 2007 Share Posted February 17, 2007 yep your ready to go. go for it. good luck. Link to comment https://forums.phpfreaks.com/topic/38883-solved-zip/#findComment-186992 Share on other sites More sharing options...
plutomed Posted February 17, 2007 Author Share Posted February 17, 2007 i dont get how you use these functions to extract a zip file ??? Link to comment https://forums.phpfreaks.com/topic/38883-solved-zip/#findComment-186996 Share on other sites More sharing options...
printf Posted February 17, 2007 Share Posted February 17, 2007 i dont get how you use these functions to extract a zip file ??? A simple example, if the zip has a directory structure you will need to include that logic, this example only reads files! <?php // zip file to open and read $zip_file = './path/name_of_file.zip'; // place to extract zip file to $extract_to = './path_to_extract_to/'; // try to open the zip file $zf = zip_open ( $zip_file ) or die ( 'FILE ERROR: can not open to unzip, ' . $zip_file . '!' ); // array container to hold the file names found in the zip file $files = array (); // keep reading until there is no files left to read while ( $zs = zip_read ( $zf ) ) { // do we have a valid file to read if ( zip_entry_open ( $zf, $zs, 'rb' ) !== false ) { // read the complete file $zo = zip_entry_read ( $zs, zip_entry_filesize ( $zs ) ); // get the file name $fn = zip_entry_name ( $zs ); // save the file to the extract directory $fs = fopen ( $extract_to . $fn, 'wb' ); fputs ( $fs, $zo ); fclose ( $fs ); // add the file name to are information array $files[] = $extract_to . $fn; } } // done, release the resource zip_close ( $zf ); // just show the files in the zip file information array echo '<pre>' . print_r ( $files ) . '</pre>'; ?> Link to comment https://forums.phpfreaks.com/topic/38883-solved-zip/#findComment-187066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.