The PHP script [FONT="Courier New"]includes/modules/pages/download/header_php.php[/FONT] creates a temporary subdirectory in directory pub, although [FONT="Courier New"]pub[/FONT]'s permissions are identical to all other Zen Cart directories (755):
drwxr-xr-x 3 zcnb zcnb 4096 Jul 24 16:24 pub
I was trying to create a temporary file in the download directory in the same manner, in that same exact [FONT="Courier New"]includes/modules/pages/download/header_php.php[/FONT] file, but that operation fails. I understand that for security reasons, the script handling customer's download session should not be able to write/create a file in any directory. But the fact that Zen Cart is able to do so inside the same PHP script I am trying to modify, hints that there is a way to succeed in what I am trying to accomplish.

What is the proper way to create/copy a file (on the fly, as a result of the customer clicking the 'download' button) inside the [FONT="Courier New"]download[/FONT] directory?

Thanks,
Daniel