This script must be run from a directory that the web server has permission to write to.
Solution: Try creating a directory such as /export/home/pub-mgt/cgi-bin/temp, make sure the user the web server runs as has write permission there, then move this script into that dir and browse to it.