Coldfusion - Saving the File Name for Image Uploader Applet

Discussion in 'Programming' started by CFPadawan, Aug 19, 2009.

  1. #1
    I have recently purchased a Java Image Uploader from http://www.javaatwork.com/java-upload-applet/samplecode.html#coldfusion does anyone have any coding that will allow me to save the image name in a MySQL db during or after a sucessful upload.

    Any help would be great.

    Thanks in advance.
     
    CFPadawan, Aug 19, 2009 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just fyi, that sample is not a good example of well written CF code. I am not even sure it works. You would be better off using the livedocs example

    http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_f_10.html#3540091

    ... or one of these guides.
    http://www.coldfusionjedi.com/index.cfm/2007/10/12/File-Upload-Guide
    http://www.coldfusionjedi.com/index...u-aware-of-the-MIMEFile-Upload-Security-Issue

    But, to answer your question about that specific example, you use <cffile..> to do the upload. CF then populates a structure named #CFFILE# (or the "result" attribute) with details like the fileName, extension, the directory it was saved to etctera. You can view all of file properties, by dumping the #CFFILE# structure just after your upload:

    <cffile action="upload" ...>
    <cfdump var="#CFFILE#">


    You then use the #CFFILE# structure in combination with <cfquery ..> to extract and store the filename in your database.

    <cfquery ...>
    INSERT INTO SomeTable (SavedFileName)
    VALUES ( <cfqueryparam value="#CFFILE.serverFile#" cfsqltype="cf_sql_varchar"> )
    </cfquery>


    Out of curiosity, why do you need a separate image uploader? ie What does it do that you cannot do with a regular form?
     
    cfStarlight, Aug 19, 2009 IP
  3. CFPadawan

    CFPadawan Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks your prompt reply, I am relatively new to CF and have only been developing for the last year. I basically am looking to create a cfform that allows a user to upload up to 5 images, restricts file uploads to 2gb and stores the filename in the database, once uploaded the form action redirects the user to to a another page.

    Any example coding instead of using Java to Work would be greatly apprecieted. :)

    Gaz.
     
    CFPadawan, Aug 19, 2009 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I am not suggesting you use java. I was asking what features does the applet give you, that a regular cfform upload does not.

    The links above give a good example of creating an upload form in CF. The concept is not that different for multiple images. What part are you having difficulty with?
     
    cfStarlight, Aug 20, 2009 IP