Why is the file I uploaded locked by ColdFusion 10? -


i'm trying delete file if not spreadsheet, keep getting following error when uploaded testfile.text: coldfusion not delete file d:\coldfusion10\cfusion\runtime\work\catalina\localhost\tmp\testfile.text

i verified not permission issue, because if go , execute code try delete file again, work.

<cffile action="upload" destination="#dest#" filefield="xlsfile" result="upload" nameconflict="makeunique">   <cfif upload.filewassaved>     <cfset thefile = dest & upload.serverfile>      <cfif isspreadsheetfile(thefile)>         <cfspreadsheet action="read" src="#thefile#" query="data" headerrow="1">         <cfset showform = false>     <cfelse>         <cfscript>             thisfile = thefile;             fileread = createobject("java", "java.io.fileinputstream");             thisthread = createobject("java", "java.lang.thread");             loopct = 1;             while(1 eq 1) {     try     {         fileread.init(thisfile);         break;     }     catch(any ecpt)     {         thisthread.sleep(1000);     }     incrementvalue(loopct);     if(loopct gt 60)     {         fileread.close();         return;     } }  loopct = 1; while(1 eq 1) {     sizea = fileread.available();     thisthread.sleep(1000);     sizeb = fileread.available();     if(sizea eq sizeb)     {         thisthread.sleep(1000);         sizec = fileread.available();         if(sizec eq sizeb)         {             break;         }     }     incrementvalue(loopct);      if(loopct gt 60)     {         fileread.close();         return;     } } fileread.close();  <script type="text/javascript">  </script>           </cfscript>          <!--cffile action="delete" file="#thefile#"-->         <cfset errors = "the file not excel file.">         <span style="font-size:medium;font-weight:bold; color:red"><p>the file not excel file!<p></span>         <input type="button" value="try again" class="button" onclick="window.location='bulk_upload.cfm'">         <br><br><br>     </cfif>     <cfset errors = "the file not uploaded.">  </cfif> 

i ran exact same issue regards cfimage locking file , preventing deletion. solution came follows. maybe can adapt situation:

<cflock name="[lockname]" timeout="5" >     <cfcache action="flush">      <!---[] replace cfimage read function (cf bug work around)  --->    <cfscript>        imageobj   = createobject( "java", "java.awt.toolkit" );       imagetools = imageobj.getdefaulttoolkit();       objimage   = imagetools.getimage( "#fullpath#" );       <!---whatever image need image, or file...--->       <!---such ---- myimagestruct["width"] = objimage.getwidth();--->        <!--- , flush object--->       objimage.flush();    </cfscript>  </cflock> 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -