lifegauge
asked on
Check filesize before CFFILE upload
Currently, I have 1 file upload field, for which I'm using "CGI.CONTENT_LENGTH" to check the size of the file before uploading it to my server.
I'm thinking of allowing multiple uploads by using the tutorial from devarticles.com:
(Upload.cfm)
<cfset numberoffields = 10>
<form action="Upload_action.cfm" enctype="multipart/form-da ta" method="post">
<cfloop index="i" from="1" to="#variables.numberoffie lds#" step="1">
<cfset filename = "file" & #i#>
<input type="File" name="<cfoutput>#variables .filename# </cfoutput >" /><br />
</cfloop>
<input type="Submit" name="upload" value="upload" />
</form>
(/Upload.cfm)
(Upload_action.cfm)
<cfloop index="i" from="1" to="#variables.numberoffie lds#" step="1">
<cfset filename = "form.file" & #i#>
<cfif evaluate(variables.filenam e) neq "">
<cffile action="UPLOAD"
destination="c:cfusionmxww wroottestf iles"
nameconflict="OVERWRITE"
filefield="#variables.file name#">
</cfif>
</cfloop>
(/Upload_action.cfm)
My question is: How do I check the filesize of *every* upload field with CGI.CONTENT_LENGTH with the above code?
I'm thinking of allowing multiple uploads by using the tutorial from devarticles.com:
(Upload.cfm)
<cfset numberoffields = 10>
<form action="Upload_action.cfm"
<cfloop index="i" from="1" to="#variables.numberoffie
<cfset filename = "file" & #i#>
<input type="File" name="<cfoutput>#variables
</cfloop>
<input type="Submit" name="upload" value="upload" />
</form>
(/Upload.cfm)
(Upload_action.cfm)
<cfloop index="i" from="1" to="#variables.numberoffie
<cfset filename = "form.file" & #i#>
<cfif evaluate(variables.filenam
<cffile action="UPLOAD"
destination="c:cfusionmxww
nameconflict="OVERWRITE"
filefield="#variables.file
</cfif>
</cfloop>
(/Upload_action.cfm)
My question is: How do I check the filesize of *every* upload field with CGI.CONTENT_LENGTH with the above code?
ASKER
It is possible, as mentioned above, I'm using it to determine the filesize of 1 field now.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you don't need FileRead the size is already available to you after using upload, cffile.fileSize as I said before in my answer.
I just came across this post, there definitely is a way and using coldfusion to check the file size before uploading, I have a method currently I built that has a hook into java to read the byte array of the neo.tmp file prior to the image ever getting to the server, not only can I read in the filesize but I can also determine the file type without ever having to place it on the server.
Anyway, just thought I'd toss that out there, if anyone's interested I'll post some example code...
Anyway, just thought I'd toss that out there, if anyone's interested I'll post some example code...
I have this problem as well and am interested in trailblazzyr55's solution. Can you post the example code? THANK YOU.
To learn the filesize you need to upload the file first, or perform the check with some activex control or java applet probably, with cf you cannot determine the filesize before it uploaded.