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

How to get form upload value...?

New Here ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

Hi, I'd like to know how to get form upload value?
I have my initial page, index.cfm that has a upload input box (named "fileToUpload")that submits to action.cfm. In action.cfm I tried to get the value of the input by doing <cfoutput>#form.fileToUpload#</cfoutput> but instead I got a string like ("E:\JRun4\servers\cfusion\SERVER-INF\temp\cfusion-war-tmp\neotmp5263.tmp"), I expected it to be the value that was in the upload input field (i.e. "E:\My Pictures\Flowers.jpg"). How do I get this?
Thanks,
noijet
TOPICS
Advanced techniques

Views

740

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
LEGEND ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

1) Read the documentation about uploading files.

2) You got what you should have got. ColdFusion does not get the file
from the client, ie @ E:\\My Pictures\Flowers.jpg. When the form was
submitted, the browser got the file and sent to the server as part of
the response. The server then saved it in a temporary location as you
noted @
E:\JRun4\servers\cfusion\SERVER-INF\temp\cfusion-war-tmp\neotmp5263.tmp.

3) To do something with this you will use at least a <cffile
action="upload" ...> (see <cffile documentation). More logic is
probably required, depending on what you want to do after that.

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
New Here ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

Hi Ian, thanks so much for your reply:

I actually do the uploading this way(I have to save directly to DB):
<cffile action="readbinary" file = "#FORM.fileUpload#" ...> and then I use this to insert into my DB. I can't do something like "#cffile.clientDirectory#" right? What else can I do?

Thanks so much,
noijet

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
LEGEND ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

CFFILE.ServerFile

http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000192.htm#2712126
CFFILE ACTION=Upload variables
File variables are read-only. Use the CFFILE prefix to reference file
variables; for example, CFFILE.ClientDirectory. The File prefix is
deprecated in favor of the CFFILE prefix.

CFFILE.AttemptedServerFile
CFFILE.ClientDirectory
CFFILE.ClientFile
CFFILE.ClientFileExt
CFFILE.ClientFileName
CFFILE.ContentSubType
CFFILE.ContentType
CFFILE.DateLastAccessed
CFFILE.FileExisted
CFFILE.FileSize
CFFILE.FileWasAppended
CFFILE.FileWasOverwritten
CFFILE.FileWasRenamed
CFFILE.FileWasSaved
CFFILE.OldFileSize
CFFILE.ServerDirectory
CFFILE.ServerFile
CFFILE.ServerFileExt
CFFILE.ServerFileName
CFFILE.TimeCreated
CFFILE.TimeLastModified

--
Ken Ford
Adobe Community Expert


"noijet" <webforumsuser@macromedia.com> wrote in message
news:efc7gq$n7s$1@forums.macromedia.com...
> Hi, I'd like to know how to get form upload value?
> I have my initial page, index.cfm that has a upload input box (named
> "fileToUpload")that submits to action.cfm. In action.cfm I tried to get
> the
> value of the input by doing <cfoutput>#form.fileToUpload#</cfoutput> but
> instead I got a string like
> ("E:\JRun4\servers\cfusion\SERVER-INF\temp\cfusion-war-tmp\neotmp5263.tmp"),
> I
> expected it to be the value that was in the upload input field (i.e.
> "E:\My
> Pictures\Flowers.jpg"). How do I get this?
> Thanks,
> noijet
>


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
New Here ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

Hi Ken, thanks so much for taking the time out to answer. I'm currently not doing <cffile action="upload...> instead I'm doing <cffile action="readbinary" file = "#FORM.fileUpload#" ...>, that is why I can't seem to get the variables, like CFFILE.ClientDirectory, CFFILE.ClientFile... Do you have any options for me?

Thank you,
noijet

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
LEGEND ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

I think the file has to be on the server.

http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000251.htm#3545306

cffile action = "readBinary"

Description

Reads a binary file (such as an executable or image file) on the server,
into a binary object parameter that you can use in the page.

--
Ken Ford
Adobe Community Expert


"noijet" <webforumsuser@macromedia.com> wrote in message
news:efcff2$31a$1@forums.macromedia.com...
> Hi Ken, thanks so much for taking the time out to answer. I'm currently
> not
> doing <cffile action="upload...> instead I'm doing <cffile
> action="readbinary"
> file = "#FORM.fileUpload#" ...>, that is why I can't seem to get the
> variables,
> like CFFILE.ClientDirectory, CFFILE.ClientFile... Do you have any options
> for
> me?
>
> Thank you,
> noijet
>
>


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
New Here ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

Hi Ken, thanks so much for your reply. I'm a cf newbie, so many thanks for your help. My project requires me to save image directly to sql server 2000. So I guess cffile action = "readBinary" is really my only option, do you have any ideas how I can get the client's directory b/c it gets converted to the neotemp#.tmp file? I was thinking about using javascript but the client may shut it off ?

Thanks so much Ken,
noijet

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
LEGEND ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

LATEST
Upload the file first, then write it to the database:

http://www.forta.com/blog/index.cfm?mode=entry&entry=A61BC976-3048-80A9-EF7AE4D7D8F602B9

<cffile action = "upload" destination = "c:\CFusionMX\temp\" nameConflict =
"overwrite" fileField = "Form.FileToUpload" >

<cffile action = "readbinary" file = c:\CFusionMX\temp\#cffile.serverfile#"
variable = "binImage">

<cfquery name="PutPicture" datasource='#DSN#' username='#LoginDB#'
password='#PasswordDB#'>
insert into CFR_PICT (CFR,PICTURE)
values ('Cfr1' , <cfqueryparam cfsqltype="cf_sql_blob" value="#binImage#">)
</cfquery>


--
Ken Ford
Adobe Community Expert


"noijet" <webforumsuser@macromedia.com> wrote in message
news:efcj70$72q$1@forums.macromedia.com...
> Hi Ken, thanks so much for your reply. I'm a cf newbie, so many thanks
> for
> your help. My project requires me to save image directly to sql server
> 2000.
> So I guess cffile action = "readBinary" is really my only option, do you
> have
> any ideas how I can get the client's directory b/c it gets converted to
> the
> neotemp#.tmp file? I was thinking about using javascript but the client
> may
> shut it off ?
>
> Thanks so much Ken,
> noijet
>


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