Image upload failure in WordPress

Posted by Mike

OK, you may remember seeing a little image in my last (first) post. Well, getting that to appear wasn’t quite as straightforward as I’d hoped. When I first tried to upload an image from my computer, I got an error message:

failed to write to disk

So obviously something strange was happening at my servers end – I initially thought it might be read/write permissions, but after a brief search on the WordPress forums, and another quick email to my hosting support, it turned out that I needed to set up a couple of customised php settings on my site. This might not be the case with every hosting provider, but I needed to go to my site control panel and click PHP settings and set the upload_tmp_dir to be /tmp . And also in my case I to actually create the /tmp directory itself (I guess up until now I didn’t really see the need to have one…)

But I wasn’t quite there yet. When I tried again, I got a brand new error

Unable to create directory
…………./blog/wp-content/uploads/2008/10. Is the parent directory writable by the server?

Now that smelt even more like file permissions than the last time – and sure enough that’s what it was.

Another quick scout around WordPress.org and I saw that they do say “A default WordPress installation comes with permissions settings for its files and folders (i.e. directories) that can be regarded as very secure.” I should say so. Particularly having a content folder into which you can’t actually place your content.

But they do give comprehensive instructions on how to change various permissions to get things working more smoothly. See Changing File Permissions for more information on this.

It’s also worth looking at htaccess for subdirectories which explains how to put back some of the security on folders that you’ve allowed more write access to – for example, restricting uploads of only image files (JPG, GIF, PNG) to that /tmp directory.

OK, with that all sorted, I’m fast approaching the time for customisation. Although the default template is sweet enough, I want to get my sticky paws on the HTML and CSS..

3 Comments

  • John says:

    Mike

    You seem to have had the exact same troubles that I did about a year ago when I created my site on a supanames server. At the time I managed to get it sorted, but now that I'm doing another site, I can't for the life of me remember how I solved it. Yours is the only post I've come across that seems to address the supanames specific issue, but I'm still not getting beyond the 'Failed to write to disk' message. Supanames reckoned it would take up to 12 hours for the tmp file to work, but I'm beyond that now and nothing has changed. How long did it take between you making the tmp directory and then getting the new error message?

    Thanks
    John

  • Mike says:

    Hi John,
    Although it says on the Supanames control panel that changes to the php upload_tmp_dir will take up to 24 hours, I was told by Supanames support that it shouldn't take more than an hour at most these days. As I recall it was within the hour for sure.

    I've just checked my control panel – the other thing I've done in PHP settings is set the 'session_save_path' to /tmp also.

    Try that, if you're still getting the first 'Failed to write' message then it might be worth double checking that the tmp directory is in the root of your space and has the right permissions?
    Let me know how you get on.

    Good luck!
    Mike

  • John says:

    Well I tried a few things all at once and one of them worked! Thanks very much for your help, it may have been the secret to success. All the best, John

Leave a Reply

Your email address will not be published. Required fields are marked *