in reply to Temp file strategy

1) There are modules that generate uniquely named temporary files. (Search CPAN for "temporary files".)

2) Save the file name in the session. Have the session delete the file when it gets deleted.