Skip navigation
Currently Being Moderated

passing data using cffileupload

Apr 29, 2011 8:02 AM

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?

 
Replies
  • Currently Being Moderated
    Apr 30, 2011 9:06 AM   in reply to Gene Godsey

    when using cffileupload (http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461 172e0811cbec18238-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/WSc3ff6d0ea77859461 172e0811cbec22c24-7388.html

     

    hope this helps out

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2011 10:41 AM   in reply to Gene Godsey

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2011 5:40 AM   in reply to Gene Godsey

    <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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2011 6:20 AM   in reply to Gene Godsey

    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

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2011 9:34 AM   in reply to Gene Godsey

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 21, 2012 5:34 PM   in reply to Gene Godsey

    Not cool

     
    |
    Mark as:
  • Currently Being Moderated
    May 24, 2012 3:01 PM   in reply to Gene Godsey

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 24, 2012 5:23 PM   in reply to djeddieflux

    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.

    
     
    |
    Mark as:
  • Currently Being Moderated
    May 19, 2013 9:26 PM   in reply to talofer99

    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...

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points