Home > PHP, Programming > Php copy .. failed to open stream: Permission denied in …

Php copy .. failed to open stream: Permission denied in …

Ever faced this problem when you’re trying to copy files using php? Well, as the error above said, you’re having a permission problem to access the source and/or destination file. I’ll describe two possible ways to overcome this problem:

1)If this problem happened on your local pc, you’ll just have to right click on the folder where the file resides, click Properties, and make sure the Read Only Attributes is not checked. Try running the code again.
2)If this problem happened on your internet(hosting) server, you’ll have to set the permission of the folder. If you’re using CPanel, go to File Manager, and browse to the parent directory of the folder, check (tick) the folder name, and click on the ‘Change Permissions’ button. Try enabling the folder’s Read, Write, and Execute for World and Group. Try running the code again.

For security reasons, after you’re sure that the code works, don’t forgot to tweak the permission settings so that only the minimal permission is granted. Sure you don’t want anyone out there to overwrite your files, don’t you?

Hope this post helps somebody out there!

Categories: PHP, Programming Tags:
  1. No comments yet.
  1. No trackbacks yet.