coldfusion
cf中上传可以控制大小吗?如何控制?
[解决办法]
上传前可以先得到文件大小,之后再决定是否要上传。
cfhttp.responseHeader["Content-Length"] 这个可以知道大小。
[解决办法]
学习下
[解决办法]
这里有个例子:
来自:easycfm
<CFIF isdefined ("FORM.Upload")>
<CFIF VAL(CGI.CONTENT_LENGTH) GT 20000>
<cflocation addtoken="no"
url="index.cfm?Note=File too Large! (#VAL(CGI.CONTENT_LENGTH/1000)# KB)">
<CFABORT>
<CFELSE>
<CFFILE
ACTION="Upload"
FILEFIELD="UploadMe"
DESTINATION="C:\uploads"
NAMECONFLICT="OVERWRITE">
<cflocation addtoken="no"
url="index.cfm?Note=File Uploaded (#VAL(CGI.CONTENT_LENGTH/1000)# KB)">
<CFABORT>
</CFIF>
</CFIF>
<html>
<head>
<title>Upload</title>
</head>
<body>
<cfparam name="URL.Note" default="">
<CFOUTPUT>
<strong><font color="RED">#URL.NOTE#</font></strong>
</CFOUTPUT>
<form action="index.cfm" method="post" enctype="multipart/form-data">
<input name="UPLOAD" type="hidden" value="Y">
Source File Name:<BR>
<INPUT NAME="UploadMe" TYPE="File" SIZE="50"><BR>
<input type="Submit" value="Upload Now">
</form>
</BODY>
</HTML>