ColdFusion:上传的文件中没有收到数据 [英] ColdFusion: No data was received in the uploaded file
本文介绍了ColdFusion:上传的文件中没有收到数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的错误报告告诉我,当用户尝试将空文件上传到我的服务器时发生错误(不要问为什么用户这样做 - 我不知道),现在我想捕获该异常说在上传的文件中没有收到数据。我想知道是否有一个比在< CFFILE action =upload> $ c>周围放置
< CFTRY>
$ c>像这样:
My error report told me that an error has occurred when an user tried uploading an empty file to my server (don't ask why the user did that - I don't know) and now I want to catch that exception which said "No data was received in the uploaded file". I wonder if there is a better way than putting a <CFTRY>
around the <CFFILE action="upload">
like this:
<CFTRY>
<CFFILE action="upload" destination="#expandpath("upload")#" filefield="form.file" nameconflict="makeunique" />
<CFCATCH>
<!--- handle that error --->
</CFCATCH>
</CFTRY>
推荐答案
Try / Catch是我通常处理它的方式。
Try/Catch is the way I usually handle it.
<cftry>
<cffile action="upload" ...>
<cfcatch type="any">
<cfif Find("Saving empty (zero-length) files is prohibited", CFCatch.Detail) GT 0>
<!--- Create a zero length file on disk and continue processing as usual --->
<cffile action="write" file="..." output="">
<cfelse>
<cfrethrow>
</cfif>
</cfcatch>
</cftry>
这篇关于ColdFusion:上传的文件中没有收到数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文