Does WordPress fail to upgrade or upload?
I had recently an issue on one of my customers website which puzzled me. I was getting an error while uploading a new media or if I tried to automatically update plugins. I was getting an ungraceful error.
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 177 Warning: 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..
On the other hand, uploading a new media brought to a similar failure.
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 177 Dismiss“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/2012/02.
It showed up at first when I deployed the website, from production to the final domain. A clean installation on the same domain had not the same issue. It wasn’t theme related either. So, what was that?
I had little luck changing permissions of the folder involved. Neither setting everything up with 755 or 777 changed a thing.
The solution
Finally I found out a fix which I believe being quite bulletproof. In the config.php file, just before the line
/* That's all, stop editing! Happy blogging. */
I added few additional instructions.
/* 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/tmp/') ;
/* That's all, stop editing! Happy blogging. */
Done that, I do believe it’s a good idea to actually create a folder called tmp in wp-content. It’s also a good practice keeping order in the wp-content folder. That way the day you will have to backup or restore, you will know which files are temporary and not strictly necessary (probably left over of unsuccessful processes – delete!).
Let me know if the solution works for you. Happy coding!

Works great for our environment!
Most of the other solutions to this problem suggested allowing write access to the wp-content directory for the user running the web server. Some solutions even suggested setting chmod 777 for the directory. BAD IDEA!!!!
We chose your solution because it was elegant, secure, and should continue to work with future versions of WordPress.
Thanks Andy, very kind words from you. Glad to be useful!