Below you will find a step-by-step tutorial to fix the “Missing a Temporary Folder” error in WordPress and the issue of not being able to upload images or files. This specific case occurred on a server with VestaCP, but the steps are similar on any hosting with open_basedir configurations and folder permissions.
1. Problem Description
When trying to upload an image in WordPress (under Media → Add New), the error appears:
“Missing a temporary folder”
(or in some versions, “The uploaded file could not be moved to…”)
Also, in the server error logs, messages like the following can be seen:
sqlCopyPHP Warning: Unknown: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s)...
File upload error - unable to create a temporary file in Unknown on line 0
It may also be that after fixing open_basedir, a new error appears:
“The uploaded file could not be moved to wp-content/uploads/…”
This indicates a permissions problem in the uploads folder.
2. Main Causes
open_basedirrestriction: PHP is trying to use/tmp(or some temporary folder), but it is not included in the list of directories allowed byopen_basedir.- Permissions on the
uploadsfolder: The user running PHP/Apache (for example,www-data) does not have write permissions onwp-content/uploads.
3. Two-Part Solution
3.1. Add :/tmp to the open_basedir directive
On many servers with VestaCP, the open_basedir directive is not defined directly in /etc/php/7.x/apache2/php.ini, but rather in domain-specific configuration files. To find them:
- Search where the
open_basedirdirective is defined- Connect via SSH and check the domain configuration folder:bashCopy
cd /home/USER/conf/web grep -Ri open_basedir . - In our example, the user is
clientand the domain isclient.com.mx. Files found include:arduinoCopy/home/client/conf/web/client.com.mx.apache2.conf /home/client/conf/web/client.com.mx.apache2.ssl.conf - Inside these files, a line like this was found:iniCopy
php_admin_value open_basedir /home/client/web/client.com.mx/public_html:/home/client/tmp
- Connect via SSH and check the domain configuration folder:bashCopy
- Edit to include
:/tmp- Open each file with an editor (e.g.,
nano) and modify the line:iniCopyphp_admin_value open_basedir /home/client/web/client.com.mx/public_html:/home/client/tmpto this:iniCopyphp_admin_value open_basedir /home/client/web/client.com.mx/public_html:/home/client/tmp:/tmp - Save the changes.
- Open each file with an editor (e.g.,
- Restart the service
- If you use Apache with mod_php:bashCopy
systemctl restart apache2 - If you use PHP-FPM:bashCopy
systemctl restart php7.2-fpm - Adjust the
7.2version as appropriate.
- If you use Apache with mod_php:bashCopy
- Verify with
phpinfo()- Create or check
info.php(inside your site) with:phpCopy<?php phpinfo(); - Access
https://yourdomain.com/info.phpand locate “open_basedir” in the “PHP Core” section. - Make sure the Local Value includes
:/tmp.
- Create or check
This will remove the “open_basedir restriction in effect” error and the “Missing a temporary folder” warning. PHP will be able to use /tmp without restrictions.
3.2. Adjust permissions on the uploads folder
After fixing the open_basedir part, you might still see an error like:
“The uploaded file could not be moved to wp-content/uploads/2025/01.”
This indicates that the user running PHP/Apache (for example, www-data) does not have write permissions on wp-content/uploads (and subdirectories).
- Identify the Apache/PHP user
- On Ubuntu/Debian, it is usually
www-data. On CentOS, it’s oftenapache. - If you use VestaCP with PHP-FPM, sometimes it runs as the account user (e.g.,
client). But in this case, Apache/PHP was running aswww-data.
- On Ubuntu/Debian, it is usually
- Inside those files, a line like this was found:iniCopy
php_admin_value open_basedir /home/cliente/web/cliente.com.mx/public_html:/home/cliente/tmp - Edit to include
:/tmp- Open each file with an editor (for example,
nano) and modify the line:iniCopyphp_admin_value open_basedir /home/cliente/web/cliente.com.mx/public_html:/home/cliente/tmpso it looks like this:iniCopyphp_admin_value open_basedir /home/cliente/web/cliente.com.mx/public_html:/home/cliente/tmp:/tmp - Save the changes.
- Open each file with an editor (for example,
- Restart the service
- If you use Apache with mod_php:bashCopy
systemctl restart apache2 - If you use PHP-FPM:bashCopy
systemctl restart php7.2-fpm - Adjust the
7.2version as appropriate.
- If you use Apache with mod_php:bashCopy
- Verify with
phpinfo()- Create or check
info.php(inside your site) with:phpCopy<?php phpinfo(); - Access
https://yourdomain.com/info.phpand locate “open_basedir” in the “PHP Core” section. - Make sure the Local Value includes
:/tmp.
- Create or check
This will remove the “open_basedir restriction in effect” error and the “Missing a temporary folder” warning. PHP will be able to use /tmp without restrictions.
3.2. Adjust permissions on the uploads folder
After fixing the open_basedir part, you might still see an error like:
“The uploaded file could not be moved to wp-content/uploads/2025/01.”
This indicates that the user running PHP/Apache (for example, www-data) does not have write permissions on wp-content/uploads (and its subdirectories).
- Identify the Apache/PHP user
- On Ubuntu/Debian, it’s usually
www-data. On CentOS, it’s typicallyapache. - If you use VestaCP with PHP-FPM configured to use the same user as the account owner (e.g.
cliente), you don’t need to change permissions towww-data. But if the process runs aswww-data, then WordPress needswww-datato have permissions.
- On Ubuntu/Debian, it’s usually
- Assign correct ownership and permissions
- From your WordPress root:bashCopy
cd /home/cliente/web/cliente.com.mx/public_html/wp-content - Change the ownership of the
uploadsfolder:bashCopychown -R www-data:www-data uploads(Replacewww-data:www-datawith the actual user/group running PHP, if different.) - Set recommended permissions:bashCopy
find uploads -type d -exec chmod 755 {} \; find uploads -type f -exec chmod 644 {} \;
- From your WordPress root:bashCopy
- Test uploading a file
- Go to WordPress → Media → Add New and upload an image or PDF.
- If permissions are correct, WordPress will be able to move the file from the temporary folder to
wp-content/uploads/YYYY/MM.
4. Conclusion
To fix the error “Missing a temporary folder” or “The uploaded file could not be moved…” in WordPress, check these two points:
- Include
/tmpinopen_basedir: edit your domain’s configuration files so thatopen_basedirallows:/tmp, then restart PHP/Apache. - Permissions on
uploads: make sure thewp-content/uploadsfolder (and subfolders) belong to the user running PHP and have write permissions (directories 755, files 644).
This way, your WordPress will be able to:
- Create temporary files without
open_basedirrestrictions. - Move uploaded files to the
uploadsfolder without permission errors.
And that’s it! You will no longer see the “Missing a temporary folder” or “The uploaded file could not be moved…” message, and you’ll be able to upload files normally in WordPress.
Español


