I am not sure if I understand your problem in full. If you use the standard file uploader widget, the system should do exactly what (i think) you are looking for.
If you just upload a file to an object, where a file is already existing, it will be overwritten.
Or do you need something else?