• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Uploaded files.

Guest
Apr 16, 2006 Apr 16, 2006

Copy link to clipboard

Copied

I've searched the archives on this and can find nothing that is any use.

I have managed to get CFFile allowing users to upload files. however, I need to be able to check the size of the file, preferably on the client side.

I've tried the CF_Upload Custom Tag from Misrazal. But it doesnt seem to work in the environment I'm using it in (Fusebox 4 in MVC)

Does anyone have a solution for this?

Views

412

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2006 Apr 17, 2006

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied



That looks like avery neat solution. But what would CGI.content_length gt 102400 do? What is CGI. What else do I need to install on the server?

I was reading the CFMX development kit and it said that Coldfusion doesnt have access to the client side file system so there was no way of checking file sizes using coldfusion.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

What else do I need to install on the server?
Nothing. Like session and server, CGI is a standard, built-in scope, that contains so-called environment variables. Here they are:

<cfdump var="#cgi#">

But what would CGI.content_length gt 102400 do
<cfif CGI.content_length gt 102400>
<!--- The variable CGI.content_length stores the length of the file to be uploaded, in number of bytes. As there are 1024 bytes in a KB, this code block sets the maximum allowable file size for upload at 100 kB.--->
<cfelse>
<!--- Use the cffile tag to upload the file submitted by form --->
<cffile action="Upload"...etc>
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

Oh my god!!!. But how does CGI.content_length know which file you're planning to upload?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

>Oh my god!!!. But how does CGI.content_length know which file you're planning to upload?

It does not know. The value of this variable is the value of "Content-Length" HTTP header that must be present in any HTTP request (this is by definition).

Unfortunately, in Cold Fusion this value is only accessible AFTER the request completely processed by the server. Therefore, if you want to restrict the size of uploads, it's too late: file has been already uploaded You may decide not to save it to a permanent location (do not execute CFFILE). So, if you really want to restrict uploads by size, you have to use a client-side solution (like applet) or a server-side (but not Cold Fusion).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

But how does CGI.content_length know which file you're planning to upload?
The Common Gateway Interface(CGI) is a standard means of communication between browsers, HTTP, web and other types of servers. The technologies may be different, but CGI enables them to pass to each other common information that is useful to all. CGI variables are an example of such information.

When the browser makes a request, like posting the upload form, the server automatically populates the variables in CGI scope with information that pertains to the request. CGI.content_length is one such piece of information. It is just information about the request, and is available to Coldfusion, even without Coldfusion actually executing <cffile action="upload"...>. To see that in action, run the following code:



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 19, 2006 Apr 19, 2006

Copy link to clipboard

Copied

LATEST
The CGI.content_length will also add up all the files you are uploading into one sum.. so it is not going to work if you are doing multiple files.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation