How do I fix WordPress PCLZIP_ERR_MISSING_FILE (-4)

Issue :
When i want to update the wordpress theme or plugin, i will get the following error “PCLZIP_ERR_MISSING_FILE (-4)”.

WordPress PCLZIP_ERR_MISSING_FILE (-4)

Solution :
1. To fix the following issue, please add define(‘WP_TEMP_DIR’, ABSPATH . ‘wp-content/temp’); right after }! and create temp folder in wp-content/temp.

if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', __DIR__ . '/' );

}
define('WP_TEMP_DIR', ABSPATH . 'wp-content/temp');

WordPress PCLZIP_ERR_MISSING_FILE (-4)

2. Create tmp directory under wp-content in documentroot

# mkdir -p /var/www/html/wp-content/tmp

3. Assign correct permission to the created tmp directory. I this case the wordpress running in nginx web server with nginx user.

# chown -R nginx:nginx wp-content/tmp

4. Edit and save the wp-config.php file.

# vim /var/www/html/wp-config.php

This will resolve the package could not be installed. PCLZIP_ERR_MISSING_FILE (-4) : The archive file error is missing and allows you to upload and update themes and plugins and sometimes appear when you want to upload a photo into a wordpress post.

Leave a Comment