Saturday, April 17, 2010

Wordpress: Upload an image by ftp and add it to the Media Library

Got a message that says: "Error saving media attachment." when you tried to upload a file to the Wordpress Media Library? This is because Wordpress has no write permission in the "wp-content/uploads"-folder.

Instead of trying to figure out your write permissions (and probably doing something stupid like giving it chmod 777), you might thought to just upload your pictures by ftp and then add it to the library using the "Add from Server" Plugin by Dion Hulse.
- But now you have a "The uploaded file could not be moved to ..." error message?

The problem is that this Plugin tries to copy the file into the uploads folder. And with no write-permission, it can't do this.

So how do we get around that?

There is a simple hack that solves that problem. The only thing you need to do, is comment out lines 192-199 in the file "add-from-server.php" of the plugin.

Now you can upload your pictures using any ftp-client to the "wp-content/uploads" folder and then include them in the Wordpress Media Library, using the "Add from Server" option. A little error message appears, but it works.

No comments:

Post a Comment