in reply to
cgi download and delete file
You know that Private SNAFU is always on duty: the mere fact that you zipped-up a bunch of files and pushed them to an HTML stream doesn’t mean that they arrived, any more than it does at the Post Office. I would therefore design this program to build the Zip files, then remove the files from whence they were made (if appropriate), then put that file into a “to be downloaded” directory under some appropriate name. From these, when the user requests a download, the file is renamed in some slight way to indicate that it “has been or is-being downloaded.” (Renaming ahead-of-time avoids any file contention issues. Moving it to a different directory ahead-of-time does the same thing.) But in every step you have thus given yourself a way out. If the download did not for whatever reason succeed, the data is still there and the process could be repeated.