I found a bug in uploading an image per xmlrpc. The upload fails if in struct['name'] is a subdirectory included eg. '2005-01-17/picture.jpg'
I have solved this problem for me in the following file serendipity_xmlrpc.php and have implemented a directory check:
Code: Select all
function metaWeblog_newMediaObject($message) {
global $serendipity;
$val = $message->params[0];
$postid = $val->getval();
$val = $message->params[1];
$username = $val->getval();
$val = $message->params[2];
$password = $val->getval();
$val = $message->params[3];
$struct = $val->getval();
if (!serendipity_authenticate_author($username, $password)) {
return new XML_RPC_Response('', 4, 'Authentication Failed');
}
// Check if Directory exists
if (!is_dir(dirname($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $struct['name']))) {
mkdir(dirname($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $struct['name']));
}
// End
$fp = fopen($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $struct['name'], 'w');
fwrite($fp, $struct['bits']);
fclose($fp);
$path = $serendipity['baseURL'] . $serendipity['uploadPath'] . $struct['name'];
return new XML_RPC_Response(new XML_RPC_Value(array('url' => new XML_RPC_Value($path, 'string')), 'struct'));
}
Kind Regards
Heinz Stampfli
heinz.st [at] mpf.li