|
Posted by soraya_soch on 05/09/07 21:45
Hi guys,
This is fairly new grounds to me, and am banging my head against the
walls with the following problem.
I have a form with a file button (multipart encoded) witch uploads a
file.
I would like that uploaded file to be caught by an rpc call and then
passed on to a server side function.
If I place the following code in different php pages, things work,
BUT, when trying to use XMLRPC, nothing happens (i get a failed with 0
errors...)
What did I do wrong?
Tia,
S.
[form.php]
....
<form id="form1" name="form1" enctype="multipart/form-data"
method="post" action="?do=upload">
<p>
<input name="file" type="file" id="file" size="40" />
</p>
<p>
<label>
<input type="submit" name="button" id="button" value="Submit" />
</label>
</p>
</form>
....
<?php
$client = new IXR_Client('http://beta.mediajena.com/xmlrpc.php');
$client->debug = true;
$DO_UPLOAD = 1;
if($_GET['do']=='upload'){
if($DO_UPLOAD == 1){
if (!$client->query('test.sendFile', $_FILES["file"])) {
die($client->getErrorCode() . ' : '.$client->getErrorMessage());
}
else{
echo $client->getResponse();
}
}
else{
echo "<br />no uploads for you. (status=$DO_UPLOAD)";
}
}
?>
[xmlrpc.php]
include_once('/functions.php');
....
$this->addCallback(
'test.sendFile',
'this:sendFile',
array('struct', 'struct'),
'Returns Bool'
);
....
function sendFile($payload){
$USER = "test";
$location = ABSPATH . "uploads/" . $USER . "/";
$val = receiveStructFile($payload, $location);
return $val;
}
[functions.php]
....
function receiveStructFile($payload, $location){
$target_path = $location . basename($payload['name']);
$_FILES['file'] = $payload;
if($msg = move_uploaded_file($_FILES['file']['tmp_name'],
$target_path)){
$msg = "done";
}
else{
$msg = $_FILES['file']['tmp_name'] . " failed with error: " .
$_FILES['file']['error'];
}
return $msg;
}
Navigation:
[Reply to this message]
|