Hi,
I'm trying to use MantisConnect to populate issues from a web form. We have that part working just fine, but we are now trying to also add an attachment to the issue.
I am using the mc_issue_attachment_add function. It works fine for attachments around 300K and less. However, anything larger is just returning a blank value to me, and nothing gets attached. I know the max size for attachments within Mantis is 2,000k, so I don't know why this is happening (and the blank error messages are maddening to try and work with).
Has anyone else ran into this, and do you have any pointers? Finding information and help on these functions has been pretty difficult, but I wouldn't be surprised if it's something simple that I've missed.
For background, my code is in PHP, and our Mantis version is 1.1.8. Here is a simplified version of what I am trying to do:
Code: Select all
$errored = false;
// $mc[] values already defined in config file
// $attachment is our uploaded file
// validate and process the attachment
// [[ do file validation here ]] //
if(!$errored) {
try {
// we need to base64 encode the attachment for sending to mantis
$fp = @fopen($attachment["tmp_name"],"r");
$tmp_buffer = "";
if($fp){
while(!feof($fp)) { $tmp_buffer .= fgets($fp,4096); }
}
@fclose($fp);
$attachment['contents'] = base64_encode($tmp_buffer);
} catch(Exception $e) {
$errored = true;
$error_msg = "There was an error uploading your file.</b> <!-- ".$e->getMessage()." -->";
}
}
if(!$errored) {
// set client and params
$client = new soapclient( $mc['soap_url'], $mc['soap_settings'] );
$add_issue_attachment_params = array($mc['soap_user'],
$mc['config_tracker_pass'],
$ticket_no,
stripslashes($attachment["name"]),
stripslashes($attachment["type"]),
$attachment['contents'] );
// now add attachment
try{
$issue_add_attachment_result = $client->__soapCall('mc_issue_attachment_add',$add_issue_attachment_params);
} catch(Exception $exception) {
var_dump($exception);
}
echo $issue_add_attachment_result;
}
Code: Select all
$mc['soap_settings'] = array('soap_version' => SOAP_1_1, 'trace' => true, 'exceptions' => true);