PHP: copy () - this is an incorrect use of file permissions

I have an image downloader on my site ...

The image is uploaded to temporary folder 777 (this image works fine and can be deleted), I then copy this file to a new directory with copy(), the new file is written to folder 777, but cannot be deleted chmod(), it does not seem to help ...

Why copy()does the function create a new file somehow different than the original file? I do not see the differences in my FTP client. Both have perms 644 and user 'nobody / 99' - but this is only a problem for the second file.

Any ideas?

+3
source share
3 answers

The problem was in the parent folder.

chmod() , 777 perms....

+3

: .

copy($temp_img_url, $save_file_as); chmod($save_file_as, fileperms($temp_img_url));
+3

Because it copy()creates a new copy of the file. Only its contents will remain unchanged. The permissions of the new file are controlled by your script parameter umask(), and the new file name is controlled by you.

+2
source

All Articles