coldfusion website - manage temporary files

My coldfusion website generates temporary files(files with exension .tmp) for some images

What is the ideal way to clean these files, how should be the temporary files managed in such websites? thanks....
at999Asked:
Who is Participating?
 
duncancummingConnect With a Mentor Commented:
I'd say setup a scheduled task to run as often as you need it to, that deletes these files.  How do you store the .tmp files?  All in one folder, or a new folder each time?  What you want to watch out for is deleting any .tmp files that are still required.  You could use the date last modified attribute (if doing a cfdirectory) if they're all in the same folder.
0
 
dgrafxCommented:
Under what circumstances are these tmp files created?
During file upload?
Could you explain a bit more - for ex. was the creation of these tmp files written on purpose by someone?
Are they under the website directory or are they in the windows ColdFusion temp directory?
0
 
_agx_Commented:
(no points please)

Some processes in CF may create temporary files. For example file uploading, charting, etc... But CF typically those files itself, automatically  So as mentioned, please clarify whether you are talking about those types of files ... or some other temporary files _you_ create explicitly within your application code.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
_agx_Commented:
>> But CF typically those files itself, automatically

Correction: ... typically REMOVES those files ... automatically
0
 
at999Author Commented:
thanks ......... actually the files gets generated by a coldfusion code - i call coldfusion function GetTempFile()
something like this
<cfset mytempFile = GetTempFile(Application.TempDir,"A1")>

what is the ideal way to clean such files... thanks
0
 
dgrafxConnect With a Mentor Commented:
without asking why are you doing this ...

<CFDIRECTORY action="list" listinfo="name" type="file" directory="#Application.tempDir#" filter="*.tmp" name="files">
<cfloop query="files">
      <cfif fileExists(Application.tempDir & files.name)>
            <cfset fileDelete(Application.tempDir & files.name)>
      </cfif>
</cfloop>
0
 
at999Author Commented:
sorry dgrafx, i forgot to mention that these tmp files  are created to create image files from oracle blob tables
0
 
dgrafxCommented:
yeah - ok
just use the code i posted
it will work

good luck
0
 
at999Author Commented:
thanks a lot to all for your help...   i will create a coldfusion schedule task to delete the temporary files - ussign cf command - fileDelete(Application.tempDir & files.name)
0
 
at999Author Commented:
thanks to all of you for the help
0
 
_agx_Commented:
>> i forgot to mention that these tmp files  are created to create image files from oracle blob tables

Just wondering ... but is there a reason you need to do this? In many cases it's not necessary to have physical files since a lot of cf tags work with blobs as well.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.