"Kola Oyedeji" <[EMAIL PROTECTED]> wrote in message
> Massimo , how would i use this cgi variable to check for the length of a
> file bieng uploaded?
This is a pretty basic example without any complex error handling, but it
should put you on the right track:
<cfif isDefined("form.photo")>
<cfset tmtFileSize="50000">
<cfif Val(cgi.content_length) GT tmtFileSize>
<cfscript>
WriteOutPut("The selected file's size is greater than the " &
#tmtFileSize# & "bytes maximun size allowed, please select another one and
try again.");
</cfscript>
<cfabort>
</cfif>
<cffile action="upload" filefield="photo"
destination="#ExpandPath("../myfolder")#" nameconflict="makeunique"
accept="image/*">
</cfif>
The benefit of using "cgi.content_length" is that you perform the check
before the file is actually uploaded.
Right now I am putting together a fairly complex routine for file uploading
to turn it into an Ultradev extension, maybe I will considered making a
custom tag out of it as well.
The beta version of the UD's extension is available from:
http://www.massimocorner.com/beta/cf.htm
If you want a fully commented version of my CFML code contact me off-list,
it's a little too much verbose to post it here.
On my website there is also a Dreamwever/Ultradev behavior callecd "Check
Image Upload". It's a client-side JavaScript solution that check for file
size and dimensions (in pixels) of an image upload. Unfortunately, it works
only on PC based browser and fail silentely on the Mac platform.
Of course, being client-side only, it's not a bullet-proof solution, but it
may be quite handy in most scenario.
Personally, I prefer to use both client and server side validation and get
the best of both worlds
Again, if you need anything more, post here or contact me directely.
----------------------------
Massimo Foti
[EMAIL PROTECTED]
----------------------------
My own Corner of the web
http://www.massimocorner.com
Dreamweaver, Ultradev and Fireworks goodies
It should be this hole in the ozone layer
But I am not the coder I use to be...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists