Does WordPress fail to upgrade or upload?

Lately I was getting an error while uploading a new media to a WordPress site. At the same time I couldn't automatically update plugins.

Warning: touch() [function.touch]: Unable to create file /home/user/public_html/website/wp-content/tmp/filename.tmp because No such file or directory in /home/user/public_html/website/wp-admin/includes/file.php on line 177Warning: unlink(/home/user/public_html/website/filename.tmp) [function.unlink]: No such file or directory in /home/user/public_html/website/wp-admin/includes/file.php on line 509

An error occurred while updating BackWPup: Download failed. Destination directory for file streaming does not exist or is not writable..

Uploading a new media was returning a similar error.

Warning: touch() [function.touch]: Unable to create file /home/user/public_html/website/wp-content/tmp/430485_368778183151054_260635637298643_1368038_1674245931_n.tmp because No such file or directory in /home/user/public_html/website/wp-admin/includes/file.php on line 177Dismiss“430485_368778183151054_260635637298643_1368038_1674245931_n.jpg” has failed to upload due to an error.

The uploaded file could not be moved to /home/user/public_html/website/wp-content/uploads/...

Changing permissions of the folder uploads did not help much. Neither setting the permissions to 755 or 777.

The solution

Finally I found a solution that worked well in my case. It may help others as well so I figure I'll post it here.

Add few new lines in the config.php.

/* Absolute path to the WordPress directory. */  
if ( !defined(‘ABSPATH’) ) { define( ‘ABSPATH’, dirname(__FILE__).’/’ ); }

/* Setup a temporary folder for uploading and updating */  
define( ‘WP_TEMP_DIR’, ABSPATH.’wp-content/temp/’) ;

/* That’s all, stop editing! Happy blogging. */  

Done that, create a new folder wp-content and call it temp.

Hopefully this will help.