Well,
This is what I have in my image upload and it works fine. The file does not get uploaded until it passes certain checks. <cfset Valid = True> <cfset VaildSZ = True> <cfset Error = ""> <cfif Not IsDefined("form.AdPhoto") or Len(form.AdPhoto) lt 3> <cfset Valid = False> <cfset VaildSZ = False> <cfset Error = Error & "<li>The Upload Photo field is required.</li><BR>"> </cfif> <cfif cgi.content_length gt #Val(APPLICATION.ALLOWEDCLADSSIZE)#> <cfset Valid = False> <cfset VaildSZ = False> <cfset Error = Error & "<li>The uploaded photo is too large. Maximum allowed size is #Val(APPLICATION.ALLOWEDCLADSSIZE)#K and yours is #cgi.content_length#K.</li><BR>"> </cfif> <cfif VaildSZ> <cftry> <!--- UPLOAD GRAPHIC TO SERVER ---> <cffile action="upload" filefield="AdPhoto" accept="#APPLICATION.ATTACHTYPE#" destination="#APPLICATION.IMAGEPATH#images-ads\cats#Val(ClassAdForPhotos.SCa tegoryID)#\" nameconflict="makeunique"> <cfset RenamePhoto = "#Val(adid)#-#DateFormat(Now(), "yyyymmdd")##TimeFormat(now(), "HHmmss")#.#File.serverFileExt#"> <cffile action="rename" source="#APPLICATION.IMAGEPATH#images-ads\cats#Val(ClassAdForPhotos.SCategor yID)#\#File.ServerFile#" destination="#APPLICATION.IMAGEPATH#images-ads\cats#Val(ClassAdForPhotos.SCa tegoryID)#\#Trim(RenamePhoto)#"> <cfset AdPhoto = "#Trim(RenamePhoto)#"> <cfcatch> <cfset Valid = False> <cfset Error = Error & "<li>The uploaded photo is not in an acceptable format. Please try again.</li><BR>"> </cfcatch> </cftry> </cfif> ----- Original Message ----- From: "Ben Nadel" <[EMAIL PROTECTED]> To: "CF-Talk" <cf-talk@houseoffusion.com> Sent: Tuesday, December 05, 2006 8:42 AM Subject: RE: Any way to limit file upload size? > I am not sure if the content_length is available until the file is > actually uploaded. I could be wrong on that though. > > > ...................... > Ben Nadel > Certified Advanced ColdFusion MX7 Developer > www.bennadel.com > > Need ColdFusion Help? > www.bennadel.com/ask-ben/ > > -----Original Message----- > From: Doug Brown [mailto:[EMAIL PROTECTED] > Sent: Tuesday, December 05, 2006 10:39 AM > To: CF-Talk > Subject: Re: Any way to limit file upload size? > > What about something like so. Am I way off? It checks before the image > is uploaded. > > > page_1.cfm > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > "http://www.w3.org/TR/html4/loose.dtd"> > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> > <title>Untitled Document</title> </head> > > <body> > <form action="page_1.cfm" method="post" enctype="multipart/form-data"> > <input type="file" name="test1"> <input type="submit" name="submitThis"> > </form> > > > <cfset allowedFileSize = 1000> > <cfif isDefined("form.submitThis")> > <cfoutput> > <cfif cgi.content_length gt "#Val(allowedFileSize)#"> Error your file is > wayyyyy to big<br> </cfif> Your file size was: #cgi.CONTENT_LENGTH# and > the allowed size was #allowedFileSize# </cfoutput> </cfif> > > </body> > </html> > > > > > Doug > > > > > > ----- Original Message ----- > From: "Snake" <[EMAIL PROTECTED]> > To: "CF-Talk" <cf-talk@houseoffusion.com> > Sent: Tuesday, December 05, 2006 7:06 AM > Subject: RE: Any way to limit file upload size? > > > > There is a setting in IIS to limit the size of form posts. But I can't > find > > it for the life of me. > > > > > > -----Original Message----- > > From: Gaulin, Mark [mailto:[EMAIL PROTECTED] > > Sent: 05 December 2006 13:29 > > To: CF-Talk > > Subject: Any way to limit file upload size? > > > > Hi > > Is there any way in CF or IIS to limit the allowed file size for a > form > with > > a file "attached"? > > > > I have a situation where someone might accidentally upload a huge file > when > > all we want is a sample file. I would want to avoid not only creating > a > > huge temp file but also all of the bandwidth needed to send the file > to > the > > server. > > > > Thanks > > Mark > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Create robust enterprise, web RIAs. Upgrade & integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262896 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4