Posted by TedH (TedH), 5 October 2005In writing a Perl based CMS, I've run across a weird thing that happens when a file is uploaded. My script can add, edit and delete the text based files nice as you please. If an image is needed I can upload to the correct folder in the webspace fine.
However, on a Windows based machine a file named CGItemp***** (***** = random number) is created in the same folder as the upload script and left there. The CGItemp file is the same size as the image that was uploaded - so I understand why it's there.
Now on Apache/Unix (evidently), this gets deleted immediately - but not on a Windows server.
This seems to be a common problem and the replies I've seen say cgi.pm takes cares of - no it does not. Only by FTP'ing in and manually delete does it go.
I've got a feeling that there must be some way to unlink any file in that folder that begins with CGItemp, but don't know it.
cheers - Ted
Posted by admin (Graham Ellis), 5 October 2005Here's an example that deletes all files that match a particular pattern in a particular directory. I've printed out the names and NOT deleted them in this test code - just uncomment the unlink line to make it work.
To change to CGItemp files, replace the \.tgz$ regular expression with ^CGItemp. I have used the "i" (ignore case) modifier because you're talking Windows in the question ....
Posted by TedH (TedH), 6 October 2005Thanks Graham, that works very nicely.
Now I can have an option for Windows users so the temporary files can be purged.
Did you ever get the directory done that you mentioned?
cheers - Ted
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho