Code:
1 |
<?php unzip_file( $file, $to ); ?> |
Ex:
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php WP_Filesystem(); $destination = wp_upload_dir(); $destination_path = $destination['path']; $unzipfile = unzip_file( $destination_path.'/filename.zip', $destination_path); if ( is_wp_error( $unzipfile ) ) { echo 'There was an error unzipping the file.'; } else { echo 'Successfully unzipped the file!'; } ?> |
Note:
- $file
- (string) (required) Full path and filename of zip archive
- Default: None
- $to
- (string) (required) Full path on the filesystem to extract archive to
- Default: None