I think you are using the code in this article to upload a file:
In fact, the code will upload the file then change the file name after uploading. When uploading, it will replace the exisiting file if a file already exists.
However,if you try to change the name of the file with existing files'. You will get this error.
I have a file with name aa.xlsx in the library:
I upload a file test.xlsx and try to rename it with aa.xlsx. I would get this error.
Infact, the file test.xlsx is uploaded successfully, but we cannot changed it name with aa.xlsx.
As a workaround, you could rename the file (test.xlsx) in the local machine (aa.xlsx). Then upload it. Just do not enter the name for the file.
It replaced the existing aa.xlsx.