I am currently implementing scraping in Ravel, but when I moved from the local environment to the staging environment, I received the error failed to open stream: Permission denied
for the file_put_contents
method.
So when I added the chmod
method to the process to change the write permissions of the file, I got the error chmod(): Operation not permitted
.How can I solve this problem?
When you write a file, change the owner and permissions of the directory to which you want to put the file as follows:
chown apache: apache/var/www/service/approot/(saveDirectory)
chmod777/var/www/service/approot/(saveDirectory)
(Of course, permissions and users vary slightly depending on the environment.If it's a shared server, it might be ftp user name.)
© 2024 OneMinuteCode. All rights reserved.