File upload to WordPress in Ecto
Update: There is a patch for the WordPress 1.2 version of the
xmlrpc.php
file that fixes this and a bunch of other things. You can find the patch here.As usual, this is unsupported by WordPress, Ecto and me.
Finally, I couldn’t live with the fact anymore that [WordPress][] does not support File upload via XML-RPC as done by [Ecto][].
I attacked the problem and the solution was astonishing simple. The code that does the upload weighs probably 20 lines. The code patches the metaWeblog.newMediaObject
method in xmlrpc.php
that was until now “unimplemented”.
You can find the patch in [xmlrpc.upload.patch][]
.
Note: In order to succesfully upload files to your blog, you’ll have to
Set an upload path in WordPress’ configuration (Options -> Miscellaneous)_ Change the permissions as required and described in WordPress’ documentation_ Patch the file
xmlrpc.php
and upload it to your WordPress install
Patching works on the command line. Put the patch and the file xmlrpc.php in the same folder. Open a terminal and change into this folder and execute the following command:
patch -p 1 < xmlrpc.upload.patch
Update: I added support for the following:
Check if uploads are allowed (Options -> Miscellaneous)_ Check if user has necessary privileges to upload files_ Check if the upload path & URL are set (not empty)* Change the mode of the file so that you have a chance of overwriting it via FTP
If any one of these conditions fails, you will get an error in ecto, indicating what the problem source is.
Disclaimer: This is a hack. I programmed this within minutes and some side-effects might apply. Changing the security settings on a folder in your web home is a potential security risk. I bear no responsibility for what you do with that patch.
Oh, and yes, I am that kind of guy who implements stuff in iterations. I think it’s called “rapid prototyping” :)
[WordPress]: http://wordpress.org[Ecto]: http://www.kung-foo.tv/ecto/index.php