How to upload a file to Atlassian Confluence page using curl
David Vonka answer is correct except for header "X-Atlassian-Token" value. It must be "no-check" (instead of "nocheck")
So corrected command is:
curl -v -S -X POST -H "X-Atlassian-Token: no-check" -F "file_0=@<file name>" -F "comment_0=<upload comment>" "http://<server>:<port>/<context>/pages/doattachfile.action?pageId=<page id>&os_username=<username>&os_password=<password>"
NOTE: replace all the <...> placeholders with your values
you need to use REST API in url: .../confluence/rest/api/content/$PAGE_ID/child/attachment
and now you are using url of view page.