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

passing data using cffileupload

Participant ,
Apr 29, 2011 Apr 29, 2011

Copy link to clipboard

Copied

I am fully aware that this is a tag adobe created using a flash interface.

I also know that it does Not need to be nested inside of a torm tag. I need to capture the

File name and the path it took to be uploaded to the server so I can insert that into a database for search functionality.

Thoughts?

Views

9.3K

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 30, 2011 Apr 30, 2011

Copy link to clipboard

Copied

when using cffileupload (http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec18238-7fd0.html) - which is the tag that creates the file uplaoder, have this attribute : URL

Basicly the file are SUBMITED/UPLOADED one at a time to that page (the one specified in the url)

so this page proccess the saveing of the uploaded image and you can use it to save things into a database.

not that if you use session in your application, add this :?#urlEncodedFormat(session.urltoken)# ? to your url in order to keep the session in the proccessing page.

here is the proccessing page tag

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7388.html

hope this helps out

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 ,
May 02, 2011 May 02, 2011

Copy link to clipboard

Copied

I tried that and it failed in the processing as well

as the flash uploader turned red. I need to find a way to successfully

upload the files and somehow track the file(s)

names so I can  insert them into a database for them to be searched and downloaded.

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 ,
May 02, 2011 May 02, 2011

Copy link to clipboard

Copied

I will assume that I will need a block of JavaScript for the oncomplete attribute.

I have ssen a few examples but that is where this is seeming to head to.

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 ,
May 02, 2011 May 02, 2011

Copy link to clipboard

Copied

When you say "Fail" what do you mean ?

I had problems with it the first time I tryed it.

What I did for debuging is to place a CFDUMP of the FORM inside a CFMAIL that was sent to me ...

this way I was sure that the form is working.

then I manged to get he files uplaoded ...

and if u get the file uploaded there is no problem to store the info on that page, as long as u pas the info for it.

for example if the file that is uploaded need to be saved for product ID#, pass that in the URL and u can do the database part on the fileuplaoding page.

If you post the code yo udo have it might be easier to help you out.

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 ,
May 02, 2011 May 02, 2011

Copy link to clipboard

Copied

All of the code I have so far is nothing more than code examples from Ben Nadel or Ray Camden.

Nothing new there.

I need to know how to do cffileupload post-processing so I can process the file names into a database for datasearches and lookups to download them for the user or consumer of the uploaded 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
Participant ,
May 02, 2011 May 02, 2011

Copy link to clipboard

Copied

I am still scouring the web for some kind of solution.

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 ,
May 03, 2011 May 03, 2011

Copy link to clipboard

Copied

I appreciate the dialogue here. I want to use this tag because it

appears to have tremendious possibilities. The following is only testing code so I understand how to work this tag

My index page is where the initial form is:

\*----------------------------------------------------*\

<cfscript>
      myNumber = "1";
</cfscript>

<cfform name="testThis" method="post" action="#cgi.SCRIPT_NAME#?postback=#url.ID#">
<cffileupload url="index_action.cfm?#urlEncodedFormat(session.urlToken)#" maxfileselect="#myNumber#" title="THIS IS RESEARCH AND DEVELOPMENT"
bgcolor="##0078ae" wmode="window"/><br />

<cfinput type="submit" name="insertit" value="GO!">
</cfform>

<cfif postback gt "0">
   #Hopefully Filenames from the uploads! :-)#
</cfif>

\*----------------------------------------------------*\

Here is the action for the cffileupload: "index_action.cfm"

\*----------------------------------------------------*\

     <cffile action="uploadall"
  destination="#expandPath('uploads')#"
  nameconflict="overwrite"
  result="server"
  />

 
  <cfset str.STATUS = 200>
  <cfset str.MESSAGE = "passed">
  <cfoutput>#serializeJSON(str)#</cfoutput>

\*----------------------------------------------------*\

My question here is How do I get the file name from the uploader so I can insert that into a database.

This is really important. I do not want to appear dull in the brain but I am not getting what you are telling me.

Please try to dumb it down so I can get the concept.

Thanks in advance.

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
Guide ,
May 03, 2011 May 03, 2011

Copy link to clipboard

Copied

<cffile action="uploadall"
   destination="#expandPath('uploads')#"
  nameconflict="overwrite"
   result="server">

Use the "result" attribute to create a variable, but don't use "server" as it's a reserved word.

Change "server" to "uploadedfiles" then add this in after:

<cfdump var="#uploadedfiles#" />

Pretty sure that should contain everything you need.

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 ,
May 03, 2011 May 03, 2011

Copy link to clipboard

Copied

ok... You are missing the BASIC of this TAG ...

IT DOSN'T WORK as CFFORM does:

You don't SUBMIT the uploaded files, they get submited in the BACKGROUND (for lack of any other wya to descirbe this).

So once the FLASH is loaded and u press upload now, the page DOSN'T get SUBMITED, what ever yo uhave in the CFFORM Tha twraps the Tag is IGNORED !!

Basicly the Flash is uplading the files to the server via http request in the background (did u actually tryed it ? di u see how it works ?)

So ....

lets say u did the follwing (which is almust all the u need or can actually place on the UPLAODING PAGE):

<cffileupload
    url = "Save.cfm"/>

The Save.cfm will look like this :

<cffile 
    action = "uploadAll"
    destination = "full pathname"
    accept = "list of MIME types"
    attributes = "file attribute or list"
    mode = "permission"
    nameConflict = "behavior"
    result = "result name">

THIS PAGE IS CALLED ONCE FOR EACH FILE THAT IS UPLOADED ....

so if u choose 4 files .. the flash will submit tem ONE AT A TIME to the UPLOAD.cfm File ....

And the acttion there will be almost teh same as if you had a reguler FORM FILE FIELD with one file ...

IF yo udon;t spcify a result = "resultname" the result structure is CFFILE ....

so if u dump the #cffile# you wil lge the name of the file uploaded and all the rest of the info. (IF itrs still not clear look at the CF reference for cffile uplaod)

BUT sayign all this ... YOU DO NOT SE The result of the SAVE.cfm PAGE .. again because this happesn in the background ...

If now things are STILL not clear ... I think maybe I'm nto the one to explain it ... and you migth consider takeing a course

HAve fun

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 ,
May 03, 2011 May 03, 2011

Copy link to clipboard

Copied

OK,

This is uploading great.

/*-----------------------------------------------------*/

<cffileupload 
    url="index_action.cfm?#urlEncodedFormat(session.urlToken)#"
    progressbar="true"
    name="myupload"
    width=400
    height=300
    title = "UPLOAD MULTIPLE FILES TO PRIVATE FOLDER"
    maxuploadsize="200"
    extensionfilter="*.jpg, *.png, *.flv, *.txt, *.doc, *.docx, *.xls, *.xlsx *.pdf"
    BGCOLOR="##0078AE"
oncomplete="?"
    MAXFILESELECT="10" />

/*---------------------------------------------------

*/

<cffile action="uploadall"
  destination="#expandPath('uploads')#"
  nameconflict="overwrite"
  result="myVar" />

  <cfdump var="#myVar#">

/*-----------------------------------------------------*/


I guess now what I need to find is a reply back with the oncomplete attribute to get me the file names.

BTW -  there is no reason to get angry about my lack of understanding here. I assure you I do not need a class.

Thanks in advance for your assistance with this issue.

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 ,
May 03, 2011 May 03, 2011

Copy link to clipboard

Copied

No one is getting upset

I just stated that if my last explantion is not enough to shad light on the subjectm I might not be the right person to anwer your Q' .. thats all ..

and I suggested to you CONSIDER takeing some form os a study group/class/course ... thats all ... only a logic suggestion ... and I'm sorry if it made u think I think you NEES a course

And read the CFFILEUPLOADER part in the manual and you will find this :

onComplete

Optional

The JavaScript function to run when a file has finished uploading.

By default, ColdFusion passes a JavaScript object as a parameter to this function with the following properties:
  • STATUS - numeric value that is based on the HTTP status code

  • MESSAGE - Passed or Failed

  • FILENAME - Name of the file selected for upload

You can also pass the JavaScript object by creating a struct with parameters "status" and "message" and call serializeJSON() on the JavaScript object.

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 ,
May 03, 2011 May 03, 2011

Copy link to clipboard

Copied

You are correct about not providing an answer. I appreciate your efforts here but may I suggest that you consider a typing or spelling class.

Understanding your comments have been a bit cryptic at best and it may help if you spell check your replies.

Hope that helps.

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 ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

Not cool

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 ,
May 19, 2013 May 19, 2013

Copy link to clipboard

Copied

I read the entire post.

I am new to coldfusion. I am using coldfusion-10. I am facing a similar issue. I am trying to upload multiple image files using cffileupload. I am able to upload files as expected. But I would like to get the metadata before uploading and get the clientFileDirectory of the uploaded files. PFB code

fileupload.cfm

<cffileupload  name = "uploadDemo"  url="uploadSelectedFiles.cfm"  progressbar="true"  addButtonLabel = "Select File(s)"  clearButtonLabel = "Clear"  width="500"  height="400"  title="Choose Files To Upload"  maxUploadSize="1"  maxFileSelect="10"  extensionfilter="*.gif,*.jpg,*.png,*.doc"  uploadButtonLabel="Upload"  onComplete="previewfile"  >  

uploadSelectedFiles.cfm

<cffile action="uploadall" destination="#expandpath('.')#"  nameconflict="makeUnique" result="uploadResult" />  <cfoutput>try</cfoutput>  <cfdump var="#cffile#"><cfdump var="#cffile.clientDirectory#">   

But cffile.clientDirectory throws an Status code :500 (unable to upload files too....).One more info, I am not able to view the 'try' string output in the main page (file upload page). Please help...

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 ,
May 24, 2012 May 24, 2012

Copy link to clipboard

Copied

actually, Talofer99 couldnt have spelled it out any simpler.

But if you need a FULLL example of how to grab the name, extension and path and insert it into the DB... then here you go:

<cffile action="uploadall"

destination="/full/path/name"

nameconflict="makeunique"

result="uploadedfile"

accept="image/*"

>

<CFSET fullimagename = "#uploadedfile.serverfilename#.#uploadedfile.serverfileext#">

<CFSET fullpath = "#uploadedfile.serverDirectory#">

<cfquery name="gallery_query" datasource="#Application.DSN#" username="#Application.Username#" password="#Application.Password#">

INSERT INTO images (image_path,

image_name)

VALUES('#fullpath#',

'#fullimagename#')

</cfquery>

You could prob do a better job at setting the name, perhaps with a date-time-id.jpg naming scheme to avoid wierd file names.

You cant get any more straight forward than 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
Participant ,
May 24, 2012 May 24, 2012

Copy link to clipboard

Copied

djeddieflux - I appricate what you wrote, to be hunst his response made me NOT want to helpeople any more, the above post was my last in any forum.

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 ,
May 28, 2014 May 28, 2014

Copy link to clipboard

Copied

LATEST

If anyone is still interested in this post, I have it working and it is easy as pie.

1) make sure you append ?#urlEncodedFormat(session.urltoken)# and any other variables to the page name in the URL attribute of the tag.  If you don't pass the url token it won't work because the AJAX used to upload the files is done behind the scenes.

2) make sure you have NO HTML COMMENTS in your application.cfc or cfm files. These will murder the JSON returned and you will get the red error in the download box.  If you have any include files in your application scope you need to check them too.  I include a file of UDF's and that is where the HTML comments were hiding.  Rules of thumb, don't use HTML comments anymore at all.  Keep in mind that ANY visible content in your application scope will have the same effect.

3) If you are still having issues, use Firefox or the Charles Proxy app to see what is being returned.  You can also use CFLOG to write the error info into a text file to be examined.

I have this working on CF9, CF10, and 11 and every time it was HTML comments in there somewhere.

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