Salesforce handles files differently depending on the UI. Attachments are linked to records in the Classic UI, while Files are managed through ContentDocument in Lightning. To upload files using the REST API, you need to create a ContentDocument for the file and then link it to a record using ContentDocumentLink.
A detailed guide on handling this, including code examples, is available here:
https://www.appseconnect.com/salesforce-file-upload-api/
This should help streamline file management across both UIs.