Thursday, February 21, 2019

php - upload or copying files / deleting




I am using a file in my main folder, httpdocs to execute this operations ( php ) on a "subdomain" folder that is outside the main folder.




The problem is I can't copy files, delete into that folder... the following error appears:




Warning: opendir() [function.opendir]: open_basedir restriction in effect. File(../ppp) is not within the allowed path(s): in / on line 25



Warning: opendir(../ppp) [function.opendir]: failed to open dir: Operation not permitted in on line 25



Answer



As PHP warning clearly states, you have a PHP instance configured to restrict your file manipulation functions to the only allowed directories. It's configured in open_basedir directive in your php.ini file.




As PHP documentation states (about open_basedir):




Limit the files that can be opened by PHP to the specified
directory-tree, including the file itself. This directive is NOT
affected by whether Safe Mode is turned On or Off.




The solution is rather simple. Open your PHP configuration file (in the most of Linux environments it's stored in a /etc/php(5?) directory and called something like php.ini) and search for open_basedir directive. Its format is similar to format of PATH environment variable on variety of OS'es.




Hope it helps and I'd like to greet the SO community. It's my first post, so I'll be glad if someone points me my mistakes during answering this question. Cheers!


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...