You can upload and associate attachments to comments via the REST API. Please note, that in order to do so, you submit the attachments first, and then subsequently link them to the comment when creating that.
Create attachment
curl -u username:password -H "Content-Type: application/binary" \
--data-binary @somefile.txt \
-X POST http://helpdesk.zendesk.com/uploads.xml?filename=somefile.txt
You will get a response containing a token, which is used to identify this file later on. Example:
<uploads token="abc123">
<attachments>
<attachment>789</attachment>
</attachments>
</uploads>
The number (789 in this case) is the id of the attachment. You can add another attachment to the same upload “batch” by supplying the just returned token:
curl -u username:password -H "Content-Type: application/binary" \
--data-binary @otherfile.txt \
-X POST http://helpdesk.zendesk.com/uploads.xml?filename=otherfile.txt&token=abc123
Which results in:
<uploads token="abc123">
<attachments>
<attachment>789</attachment>
<attachment>790</attachment>
</attachments>
</uploads>
Once you’ve uploaded the files, you can create a ticket with these attachments like so:
curl -u username:password -H "Content-Type: application/xml" \
-d "<ticket><description>Hi</description><uploads>abc123</uploads></ticket>" \
-X POST http://helpdesk.zendesk.com/tickets.xml
Or, create a comment for an existing ticket (in this case ticket 123):
curl -u username:password -H "Content-Type: application/xml" \
-d "<comment><value>Some comment</value><uploads>abc123</uploads></comment>" \
-X PUT http://helpdesk.zendesk.com/tickets/123.xml