I had this situation where i was not able to change permission of file which was 555. This was a configuration file which i badly needed to edit. I only had cpanel filemanager to change it. So i changed the permission to 777 and tried to edit it and it was showing you don’t have permission to do it. I tried to replace it and it showed the same error.
After some googling and headbanging, i remembered the permission of the folder was set to 555. As soon as i changed it to 777, everything was editable/replaceable. Ofcourse after editing, change the permissions back to default. Cheers!