[wp-trac] [WordPress Trac] #47049: Unzip_file causing Media file upload error

WordPress Trac noreply at wordpress.org
Fri Apr 26 01:03:53 UTC 2019

#47049: Unzip_file causing Media file upload error
 Reporter:  troytempleman  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Upload         |    Version:  5.1.1
 Severity:  normal         |   Keywords:
  Focuses:                 |
 When I attempt to use the unzip_file function below in my functions.php:

 require_once(ABSPATH . 'wp-admin/includes/file.php');
 $destination = wp_upload_dir();
 $destination_path = $destination['path'];
 $unzipfile = unzip_file( $destination_path.'/filename.zip',

 if ( is_wp_error( $unzipfile ) ) {
     echo 'There was an error unzipping the file.';
 } else {
     echo 'Successfully unzipped the file!';

 I get the following error when trying to upload any files into the Media
 library in Media > Add New:

 An error occurred in the upload. Please try again later.

 I am using Twenty Nineteen theme with no plugins activated and I don't get
 the error when I remove the function.


Ticket URL: <https://core.trac.wordpress.org/ticket/47049>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list