I’m creating a plugin right now that tries to download a zip file and then extract it to my plugin directory. I can download it just fine, but I can’t extract it using the unzip_file function.
Here is my code:
$path = plugin_dir_path(__FILE__); $remote_file = 'file.zip'; $local_file = $path . 'file.zip'; $ftpstream = ftp_connect('ftpname'); $login_result = ftp_login($ftpstream, 'ftp-username', 'ftp-password'); ftp_get($ftpstream, $local_file, $remote_file, FTP_BINARY); ftp_close($ftpstream);
The part above works perfecly fine, the file gets downloaded, but here is the problem:
chmod( $local_file, 0777 ); WP_filesystem(); unzip_file( $local_file, $path );
I checked and everything (downloading, giving file permission) works. It just doesn’t seem to extract and also never return any error.
I think the problem comes from calling WP_filesystem incorrecly, but I can’t find how to make it work…
Thank you for your help!
- The topic ‘Unzip_file is not working’ is closed to new replies.