I have searched for almost similar questions but none of those gave me the right answer. I have a fully working file_exist code in if else statement he
you can't call the PHP function From HTML tag like Javascript Function. you have to change your function to javascript function to invoke it like this
onclick="readexisting()"