Try following this guide for a step by step tutorial
https://www.appseconnect.com/salesforce-file-upload-api/
It lays down all the steps to upload a file in Salesforce as well as assign it to a record like an account or opportunity, all through REST APIs.
ContentVersion API to create/upload file, and ContentDocumentLink API to assign the uploaded file to a record.
Following the above guide accurately, you should not have any problem with successful file uploads.