Unable to upload images to the Media Library. Getting this erron on the console wp-admin/async-upload.php 403 (Forbidden)

I have the same problem and I think I know the answer, however, I haven’t found a way to solve the problem. When I checked all the php files in my File Manager I noticed that none of the php files ended correctly. A php code is supposed to start like this:
Each one of the files I checked until now did not have “?>” this part. But I haven’t found a way to insert it into every php file in one time. I hope this helps you in the right direction.