简体   繁体   中英

PHP - migrated files from one dir to another - permission denied for images

I have migrated files from one directory to another with:

cp -rfpn "${OLD_WWW_DIR}/users/img/." "${NEW_WWW_DIR}/users/img"

However, when I want to rewrite image in PHP script (user updates its avatar via form), I got:

Warning: imagejpeg(/var/www/new_web/www/users/img/avatar_456.jpg): failed to open stream: Permission denied in "script name" on line "xy"

How to solve this and set rights correctly during copy?

cp -rfpn

The -p option should be preserving the ownership of the file. Are you sure the permissions on the original file allowed PHP to write to it?

In Linux, you can change permissions and owner with chmod and chown respectively.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM