how to attactment jpg file on redmine server

Added by Bunsong Sum over 4 years ago

Hi all please help your idea to upload jpg using php code to redmine server

This code can add issue only, can you guide me about how to upload image to server path

i have some code below:

//$result=$client->api('issue')->all();
//$issues=$result['issues'];
if(isset($_POST['task'])) {
$data=$_POST;

/*echo '
';
        echo $data['projectId'];
        echo $data['subject'];
        echo $data['description'];
        echo '
';
*/
$issue = new Issue (
array(
'project_id'=>$data['projectId'],
'subject'=>$data['subject'],
'description'=>$data['description']
)
);
$issue->save();
//echo $issue->id;
}

?>

<form action="" method="post">
<input type="hidden" name="task" value="1" />
<table>
<tr>
<td>Project ID:</td>
<td>
<select name="projectId" class="select">

<?php 
$all=$client->api('project')->all();
$projects=$all['projects'];
foreach($projects as $project) {
?>
&lt;option value="<?php echo $project['id']; ?>">
<?php
echo $project['id'];
}
?>
&lt;/option&gt;
&lt;/select&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Subject:&lt;/td&gt;
&lt;td&gt;&lt;input name="subject" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Description:&lt;/td&gt;
&lt;td&gt;
&lt;textarea name="description" rows="10" cols="10"&gt;
&lt;/textarea&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type=submit value="Create New Issue" class="button"/&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

</form>
$result=$client->api('issue')->all();
$issue_list=$result['issues'];
?>

Thanks

Bunsong