0

i have a little problem when i try to attach file to redmine rest api, i'm using php-redmine-api-master :

if ($_FILES["file"]["error"] > 0)
    {
    echo "Error: " . $_FILES["file"]["error"] . "<br>";
    }
else{
$attachement=file_get_contents($_FILES['file']['tmp_name']);
$upload = json_decode( $client->api('attachment')->upload($attachement) );
$client->api('issue')->create(array(
    'project_id'     => 12,
    'subject'        => 'test api3 (xml) 3',
    'description'    => 'test api3',
    'assigned_to_id' => 23,
    'uploads'     => array(
        array(
          'token'       => $upload->upload->token,
          'filename'    => $_FILES["file"]["name"],
          'description' => 'MyFile is better then YourFile...',
          'content_type'=> 'image/png'
        )
    )
));
print_r($client);
}

the problem is that the file attched is saved incorrectly into redmine server !

Tim
  • 1,659
  • 1
  • 21
  • 33

1 Answers1

1

maybe your question is out of date. But i had also worked on attaching a file to a redmine issue. I didn“t have my old code yet. But i recognize that my files were also broken after uploading it.

For me the problem was the content_type. My solution was quiet simple. I toke the content_type from the upload form. Like this:

'content_type'=> $_FILES['file']['type']

Maybe this will help you here?

Henry31
  • 105
  • 1
  • 11