Linux Apache: Script PHP files do not inherit permissions from the top folder

I've created a PHP script that copies a bunch of image files to a shared folder on another server.

The shared folder has the following RWX permissions for all users / groups:

drwxrwxrwx  59 www-data  www-data  2006 19 ago 10:15 Z_LISTADO

The script is logically executed by the web server with its standard user WWW data.

The problem I have is that when copying the images, they do not inherit the permissions of the top directory Z_LISTADO, but get the following permissions:

drwxrwxrwx  6 www-data  www-data       204 19 ago 10:27 .
drw-r--r--+ 8 www-data  www-data       272 16 ago 16:05 ..
-rw-------  1 www-data  www-data   9389509 19 ago 10:27 03940.jpg
-rw-------  1 www-data  www-data   4629716 19 ago 10:27 04758.jpg
-rw-------  1 www-data  www-data  11524286 19 ago 10:27 14306.jpg
-rw-------  1 www-data  www-data   3358720 19 ago 10:27 23530.jpg

Later I can no longer use it with a user other than www-data ๐Ÿ™

Has anyone had a similar problem? I do not know if I can create an umask on Apache user level or if details are missing.

Thanks in advance.