• Home
  • Uncategorized
  • Image has failed to upload due to an error – Missing a temporary folder

Image has failed to upload due to an error – Missing a temporary folder

This error might have occured on WordPress for you: “Image has failed to upload due to an error – Missing a temporary folder”.

Reason?

  • It may be a permission issue for the php temporary folder
  • The php temp folder may not exist.

Solution?

  • Find the php.ini file for your webhost. 
  • Locate the temp folder
  • Create the temp folder if it does not exist
  • Give it proper permissions

In my case, I had transferred my site transhost, and hence this folder was actually missing.

My php.ini file (generated by i-mscp) was at this location: /var/www/fcgi/mysite/php5/php.ini

Once php.ini file was located, I needed to find the temp folder used by php:

#grep -in 'upload_tmp_dir' /var/www/fcgi/mydomain/php5/php.ini
875:upload_tmp_dir = "/var/www/virtual/mydomain//phptmp/"

Since this folder was missing, I created it and provided proper permissions and then restarted apache2:

#mkdir "/var/www/virtual/joel.co.in/phptmp/"
#chmod 755 "/var/www/virtual/joel.co.in/phptmp/"
#chown -R vu2003.www-data "/var/www/virtual/joel.co.in/phptmp/"
#service apache2 restart

Now, I could upload media files again.