;中国 COLD FUSION 用户组; WWW.CFWINDOW.COM 
您的位置 :首页 >> CF 技巧文章 >> 阅读文章内容 [ 关闭窗口 ]      

技巧文章内容 
    如何知道是否有文件被上传
文章作者 : weblu [ weblu@21cn.com ]          Web URL : http://
上载日期 : 2000-12-13


问题:当文件上传或系统创建了一个文件后,你需要一些代码来处理,进行检测。

解决方案:这段代码是由Rob Brooks-Bilson友情提供的,它可以检测文件是否存在。程序使用了一个条件循环,而且不会给服务器带来很大的负荷。


<!--- this snippet of code executes a conditional loop that continues to
itterate until one of two conditions are met.  If the file text.txt
(the example) exists, the loop breaks out. Likewise, if the timer increments
to 20000 milliseconds (20 seconds), the loop also breaks out. --->

<CFSET Continue=0>
<CFSET TimerStart = GetTickCount()>
<CFSET TotalTime = 0>
<!--- Loop until Continue = False --->
<CFLOOP CONDITION="(Continue LESS THAN 1) AND (TotalTime LESS THAN OR EQUAL TO
20000)">

<CFIF FileExists(ExpandPath("text.txt"))>
<CFSET Continue=1>
The file exists!  Done waiting...<BR>
<CFELSE>
<CFSET TimerEnd = GetTickCount()>
<CFSET TotalTime = TimerEnd - TimerStart>
</CFIF>
</CFLOOP>







< 联系我们 --- 中国Cold Fusion用户组>

CFUG 国内(总部):Linkfoxo    上海:CFANS    北京:Cafe,Cyberkid,liwater    沈阳:Wangking
  
哈尔滨:Baiming    浙江:梅盛松    江西:陈末
  
CFUG (国际) Nagoya(名古屋):Codeguru    新加坡:YUZI    新西兰(Auckland):Richard CHEN
Copyright 2000-2001 www.cfwindow.com.All rights reserved

;中国 COLD FUSION 用户组; WWW.CFWINDOW.COM