Our Blog

Custom icons in cftreeIn many cases, we upload images, so I want to show how to display the uploaded image right there in the flash form. Right now, we can only load jpgs.

In the simplest case, the file name of the picture will be the same when it gets uploaded. So in order to show it, when only need the original file name.

Besides the file upload controls, we have a couple of additional controls:

<cfformitem type="html" height="300" width="700"
   bind="<p><img src='{myform.picture}'></p>"
></cfformitem>
<cfinput type="hidden" name="picture"/>

then, in the onComplete function, we set the picture to the newly uploaded file:

//some shorcuts to our controls
var fileNameField = fileNameField;
var myform = myform;

uploadListener.onComplete = function(){
   //show the picture

   myform.picture = fileNameField.text;
}

fileNameField is the text field where we showed the name of the file to be uploaded. We assume that this field hasn’t changed since the user pressed upload and the upload was completed. We can prevent it from changing by disabling the choose button until the file has uploaded successfully or some other event (error, cancel, etc) happens.

I personally almost never use the filename that the user gives me because they usually contain spaces. So I change the file name when it gets uploaded. But that means that the form will not know what the new name is, and therefore it won’t be able to show it. To get around that, we can set the filename before hand, say the item id, or similar, and then pass that by query string to the upload action page. In that way, we can assume that the action page gave that filename to the uploaded file. You can view an example of that in the source download.

A live example
Download the source

Related posts:

File Upload with ColdFusion Flash Forms
File upload explained and expanded

Laura

Laura

90 Comments

  1. felipe
    Congrats!!! That rocks!!!

    I have a cftree that shows the folders in the server in the same form i alredy managed to pass the value of the selected folder in the tree to the upload.cfm. I would like now to add a node to the tree inside that folder with the filename after it gets uploaded, any sugestion?
  2. Todd
    Is there any way to prompt the user to download flash player 8 if they don't have it yet?
  3. Todd,
    Here you have :)
    http://www.asfusion.com/blog/entry/detecting-flash-player-8-on-a-cfform
  4. Rick
    I am trying to show a cfgraph while I am in a cfform, and the same code looks fine outside the cfform, but within I cant seem to be able to show it. I tried putting it inside a <cfformitem type="html"> but no luck either.
  5. felipe
    I need to upload a zip file with the same name of the jpg file, is there a way to manipulate de Filedata variable on the upload.cfm? I tried to do a REReplaceNoCase but it didn´t work.
  6. Gavin Dority

    Gavin Dority

    Is there anyway to call a javascript function after the upload has finished? I tried calling one with a getURL, but no dice!

    uploadListener.onComplete = function()
    {
    output.text = "Upload complete";
    getURL("javascript:alert('Test Call');");
    }
  7. Todd
    Gavin:

    No need for a javascript call. Just use an actionscript alert.

    alert(&quot;test call&quot;);

  8. Joseph Wylie

    Joseph Wylie

    What I need to do is have a button that simply uploads a file to the server. The user doesn't get to pick the file uploaded, but I would specify this in my .cfm action file. Its to do with a webcam capture screen which writes a file to the user's harddisk and the button uploads the file to the server when they are happy with the picture. The capture part works fine, just need help with the upload.

    Anyone know how to achieve this?

    Thanks
  9. James Spivey

    James Spivey

    This is a pretty sweet script. Ive been playing around a little in the hopes of having it replace a form im using now that uploads members photos for thier profile. Im having a problem though becuse for my rename, rather than pulling a random id, it needs to pull this session variable "SESSION.LoggedIn.M_ID" and everytime it pulls it, the file is just renamed to "undefined". What is the easiest way to get the SaveContent command to use a session variable?
  10. Laura
    Rick,
    You cannot have the code for cfgraph inside cfform. It will not show, as you have already found out. You either need to create the image/swf, save it and then put it in the cfformitem=html by <img src="mychart.jpg"> or generate it in a page that returns the binary data and put it in the form the same way. I believe Ray Camden has an example of that.
    http://ray.camdenfamily.com/index.cfm/2005/7/23/Embedded-CFCHART-in-Flash-Forms--Part-3

    Felipe and Joseph
    You cannot manipulate the filedata (and get a file the user hasn't chosen) nor grab am arbitrary file from the client machine and send it. Don't you think that would be pretty insecure, Flash just grabbing files from your hard drive and uploading them?

    James,
    In my example, I generate a random number, you can replace that with your session.loggedIn.m_id variable in the hidden field called id at line 144.
    <cfinput type="hidden" name="id" value="#SESSION.LoggedIn.M_ID)#" />

    if you leave everything else the same, then your upload action page will get a variable called url.id with the session id you have set in the previous page.
  11. Frank D'Elia

    Frank D'Elia

    I am getting an error 500 message when the upload completes. How can I fix this? I really want this to work, this is a great script.
  12. Rick
    Simle frank make a test.cfm page with the following code

    <FORM ACTION="upload.cfm" ENCTYPE="multipart/form-data" METHOD="POST">
    <INPUT TYPE="file" NAME="Filedata"><input type="submit">
    </FORM>


    run and see what error you get on your upload page, solve the problem and when you try your real app you should not get error 500 anymore.
  13. J. Asher Gilbert - Zealio
    There's a slight bug in that although the file selection dialog filters to a file type, it does permit *.* as a search term, and so any file type can be uploaded.

    Also, is I cancel the file dialog but then choose to 'browse...' again, all the listeners fire twice on each event. The listeners fire as many times as you've had the browse dialog open.

    This needs to be improved.

    Great job though
  14. Asher Gilbert
    Refering to my last post, I've got a little work around for the 'multiple listeners behaviour', the below code, checks to see if the swf has loaded, and if the listener has already been created, if not it creates it....

    Hope this helps...

    <cfsavecontent variable="browseScript">
       progressBarBackground.width = 255;
       var uploadSwf = textArea.label.upload;
       var panelInfo = panelInfo;
       var output = output;
       var uploadListener = {};
       var totalWidth = progressBarBackground.width;
       var fileNameField = fileNameField;
       
       var progressBar = progressBar;
       var uploadBtn = uploadBtn;
       var cancelBtn = cancelBtn;
       var maxSize;
       
       uploadSwf.addListener(uploadListener);

       uploadSwf.browse([{description: "Image Files (jpg only)", extension: "*.jpg;"}]);
       

       //this statement, checks to see that the .swf file providing the upload features of the form
       //has loaded, and makes sure that the listener has not already been created...
       //That way these events are not created every single time the browse button is clicked, so I can now use alerts()
       //inside the events, with out the risk of the the alert duplicating...

       if(uploadSwf.browse != undefined && _global.bCreatedListener == undefined){
          _global.bCreatedListener = true;
          
          _global.MathNumberParse= function(n)
          {
             return (n >> 0)+"."+ (Math.round(n*100)%100);
          }

          -------
             LISTENER EVENTS CHOPPED OUT HERE TO SAVE SPACE ON THIS POST
          -------

          }
       }   
    </cfsavecontent>
  15. George Smith
    How do you sent more info? I have the images chooser and 4 fields like a long description and other stuff. I want to press update and the image go to its place and the 4 fields to go into my sql db with an update. where does the update statement go? and how do you pass the variables?
  16. Steven Ross
    Can you guys post the source fla's now since flash 8 is out of beta? I'd really like to use this but, since sessions aren't maintained in this code it really isn't useful since there is no way I'm going to bypass my logged in app and let any old user upload files.

    thanks,

    Steven
  17. Hi Steven,
    I uploaded the source.
    http://www.asfusion.com/blog/files/cfforms/fileupload.fla

    Actually it's very simple I just have this code on the first frame:


    import flash.net.FileReference;

    var imageFile:FileReference = new FileReference();

    function addListener(listener:Object):Void
    {
       imageFile.addListener(listener);
    }
    function browse(list:Array):Void
    {
       imageFile.browse(list);
    }
    function upload( path:String):Boolean
    {
       return imageFile.upload(path);
    }
    function cancel():Void
    {
       imageFile.cancel();
    }
  18. Laura
    George,
    Uploading the file and submitting the form has to happen in two different steps. The upload only sends file data, nothing more (expect for anything needed that you can pass by query string).
    After the upload is complete, you can submit the form with the other fields like you would normally do. What you do with data of the submitted form is up to you (update/insert db, send an email, etc)
  19. George Smith
    Thats no good...
    I was kinda thinking that though. Didnt I read in one of these posts that there could be some sort of auto submision after the image file is uploaded? my problem is that people submitting images and info that corisponds with the image can get out of sink, Images without descriptions, or descriptions without images, kinda slopppy... Thanks for your help
  20. Laura
    George,
    You could, if you wanted, to automatically submit the form after upload by adding _root.submitForm() to the onComplete function code.
    What I usually do is to set up a temp directory where I upload the files. Then, when the form is submitted with the other fields, I look for the file referenced in the form and move it to its permanent directory and perhaps rename it. Anything left in the temp dir is either because the form was never submitted or people are still working on them.
    If you don't want to get description without images, just check that they have uploaded something at submit and do not submit the form unless they have done so.

    Just an idea.
  21. George
    Laura,
    Thanks for the advice but im still not getting it. I put the statement to submit after the upload in. But where should I put the &lt;cfquery&gt; update, statement? On another page? How does the form know where to go. I put an action=&quot;update.cfm&quot; in the cfform but that does not seem to do anything. I can see that the form after the image is uploaded goes to the upload.cfm where the cffile action=&quot;upload&quot; is. So where do I put the update to recieve the other form fields (input text)? Im unsure why I would want to rename and have a temp directory. Anyways thanks, your site has been very usefull.
  22. George
    Thanks,
    I got it... 6 text fields, choose file, then upload (one submit). Sooo cool
    Thanks again
  23. Will
    Is there a way to have more than one working on a single page?

    Thanks,
    Will
  24. Russ
    So how about a download file example? I need to have my use download a specific file. Is this a possibily?
  25. Justin Cook

    Justin Cook

    I have the upload working, but it doesn't display the image after it uploads it. Any ideas what I could be doing wrong?

    Thanks,
    Justin
  26. Justin Cook

    Justin Cook

    I believe the problem that I am having, pertaining to the last post I made, is that the file is being uploaded into a different folder than where the Flash form is located. I am wondering if I can do the following. Change this:

    <cfformitem type="html" height="225" width="400" bind="<p><img src='{myform.picture}'></p>"></cfformitem>

    TO:

    <cfformitem type="html" height="225" width="400" bind="<p><img src='includes\imageUploads\{myform.picture}'></p>"></cfformitem>

    Or if you all have a different suggestion.

    Tks,
    Justin
  27. Philip Bedi

    Philip Bedi

    Hi,

    This is really a question related to Flex, can we open a PDF file in Flex application or we need to open it in iframe?
  28. Justin Cook

    Justin Cook

    I have had two problems with this function:

    1. See my note above...the image doesn't display.

    2. Won't upload in Firefox or Opera. Is this supposed to work in those two? Or could I be doing something wrong and what might that be?

    Thanks in advance.
  29. Federico García

    Hi,

    I have a problem with the renamed method, when the upload is completed the file is not renamed. He creates a directory with the name of the variable myform.id and inside this save the file with the original name.

    Since I can solve this problem?

    Thank in advance.
  30. Laura
    Justin,
    1. Your syntax is correct. Your path might be wrong. Since you are using relative path, think that it is relative to where the form is located. Also, you probably want to use / instead of \
    2. It works in Firefox and Opera unless you are doing it in a password-protected area using sessions. That is a known bug. I posted a fix that's been working for me in the comments of http://www.asfusion.com/blog/entry/file-upload-with-coldfusion-flash-forms

    Federico,
    The updater made a "fix" to cffile upload. To have it working as it was, you need to install the latest hotfix or upload the file and rename it manually after.
  31. Laura
    Philip,
    No, it is not possible to embed a pdf in Flash and therefore Flex. You need to open it a new window/frame or make it Flash Paper instead.
  32. Robert
    I'm having trouble remaning the uploaded files. I have successfully passed other variable data and have created a newfilename, but I'm getting an error that the source variable, filedata, is undefined.

    <CFFILE ACTION="RENAME" DESTINATION="..\video\raw_videos\#newfilename#.avi" SOURCE="../video/raw_videos/#filedata#">

    What changes do I need to make? Thanks.
  33. KenM
    Sorry for repeating a question, but I still don't get how I submit other form elements in addition to a file upload. I have a cfform with 8 tab pages. It has text input, text area, related select lists and a editable cfgrid.

    Now I need another tab page with input areas for 3 different file names/paths. So how do I have 1 submit button that sends all of that up? Do I need a separate &quot;Upload&quot; button for each of the file inputs and after clicking those, the use then clicks the form submit? Apparently George got it - I'm still struggling.

    Thx much
  34. Laura
    Robert,
    to get the original file name, use form.filename. filedata is the actual data field, not the name.

    KenM,
    You cannot post anything other than the file. You can only send variables via query string. Otherwise, submit the form for the other fields.
    For many upload fields, you can use this custom tag:
    http://www.asfusion.com/blog/entry/file-upload-with-coldfusion-flash-forms

    check the example where the submit is triggered from another button (last example). You will trigger all the file uploads at once.
  35. Gene Rice

    Gene Rice

    I see in the code where you set the fileNameField.text = selectedFile.name, where name = name+ext, i.e. myfile.jpg

    Can I return just the name, (myfile). I want to be able to append something after that, before the extension. i.e. myfile_resized.jpg

    Thanks in advance.
  36. Laura
    Gene,
    selectedFile.name includes everything. You will need to do some string parsing if you want to separate the extension.
  37. Gomez
    i nedd know how insert value in dp after upload i try but dont work george did that?
  38. Jenny
    Laura and Nahuel,

    Thanks again for a fantastic example! You guys are awesome!

    Justin - thanks for asking that question. I was having the same issue and resolved it by reading their reply to you.
  39. Tadas
    Hi,
    i have a question:
    i use flash to upload images to database and i'm calling .net webservice to save file to database. After the images is saved, webservice returns back ID (or GUID) of the image, how can i return it back to flash swf?

    like : oncomplete, get some values from http response...

    Thanks a lot.
    Tadas
  40. Hi :)
    Thanks for this awesome info. I was wondering if it's possible to upload large music files as well. Ultimately, I'd like to find a way to upload music files, convert them to a chosen format, then put them up on a website.

    Do you know if online conversion of music has been done yet, or if it's something that will happen soon?

    Apologies that I'm not a programmer, so these may be silly questions :o)
  41. Chego Huang
    Thanks Laura,
    I hack your upload-image-renamed.cfm & upload-image-action.cfm
    We can use *.jpg;*.png;*.gif, and every onece Upload Image have a random filename.

    upload-image-renamed.cfm
    <cfsavecontent variable="uploadScript">
       var uploadSwf = textArea.label.upload;
       var id:Number = Math.floor(Math.random() * 100000001);
       myform.id = id;
       uploadSwf.upload("upload-image-action.cfm?id=" + myform.id);
    //....//


    </cfsavecontent>

    <cfsavecontent variable="browseScript">
    //....//


    uploadSwf.browse([{description: "Image Files (*.jpg;*.png;*.gif)", extension: "*.jpg;*.png;*.gif"}]);
    //....//


       uploadListener.onComplete = function(file:FileReference)
       {
          output.text = "Upload complete";
          //myform.picture = myform.id + ".jpg";

          myform.picture = myform.id + file.type;
          uploadBtn.enabled = false;
          browseBtn.enabled = true;
       }

    <cfform name="myform" height="500" width="730" format="Flash" timeout="0" skin="haloBlue">
    //....//


       <cfinput type="hidden" name="id" value="" />
    </cfform>

    upload-image-action.cfm
    <cfif structkeyexists(form,"Filedata")>
    <!--- upload file with whatever attributes you need, additional variables may come in url scope --->
       <cfset ext = Right(form.filename,4)>
       <cffile action="UPLOAD" filefield="Filedata" destination="#expandpath(".")#\#url.id##ext#" nameconflict="OVERWRITE">
    </cfif>
  42. Matt Haughey
    I keep getting a HTTP 301 error after hitting the upload button on the demo (win2003 server running apache 2.0.55)

    Any idea what's up?
  43. Laura
    Matt,
    Are you able to browse the upload.cfm file?
    For status codes, check:
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
  44. Matt Haughey
    If you mean view the upload file in an editor, yeah, I can do that.

    Here's the demo on my server:
    http://www.metafilter.com/test/upload-image/

    I have the live headers extension for firefox and I checked the apache error logs, but I'm not seeing where a 301 redirect is coming from. I assume it might be some of the /CFIDE libraries or something.
  45. Laura
    No, I mean browse it with firefox/ie. CFIDE libraries are not called in the upload, only upload.cfm.
    Unfortunately, live http headers do not show the call to the file upload script, not sure why. I've been able to see the call by using Fiddler only.
  46. Matt Haughey
    I can load it here, but I don't see any output at all:
    http://www.metafilter.com/test/upload-image/upload.cfm
  47. Eric Joseph

    Eric Joseph

    1: how do i adjust the file size?

    2: is there a way of making the image small enough so it's displayed in its entirety?

    thnx
  48. Mark Johnson

    Mark Johnson

    Hello,
    I am trying to make changes so that the image is uploaded into the /images directory instead of the root. When I change the destination - destination="#expandpath(".")#/images" like this, it will put it into the images directory but it then uses the original filename and not the old filename. Any help would be greatly appreciated.
  49. Laura
    Eric,
    1. Do you mean limiting the allowable file size?
    2. You can set the width and height in the img tag.

    Mark,
    I would store the file and then rename it afterwards. There are issues when trying to rename and save at the same time.
  50. Simon
    Hi all,

    Is it possible to upload an image say random.gif and then change the name and file extension say to userid.swf.

    Why?
    1.well the image name would be unique and identified to a user.
    2.It is possible to show a gif in flashplayer by just changing the extension. If this could be done on upload then this swf can be a gif in disguise and thus can be {binded} to things like image buttons.

    Any code hints would be appreciated thanks.
  51. Laura
    Simon,
    If you look at the source you will see we change the name of the file on the server. You can always change the file extension as well, which it does not mean the player will be able to load it or use it just because the file extension matches an allowed type.
  52. Simon
    Laura,

    Thankyou kindly for your response. Your site has become a knowledge base for me.

    I have found the section of code that changes the extension. You are right, even though changing a .gif to a swf file extension causes the gif to open in a flash player the flash player still recognises it as a gif and thus does not display it on the fly.
  53. Eric
    Laura,

    thanks for the response.

    1: yes the allowable size. to allow for bigger files, say up to 3MB

    2: would changing the height + width show the whole image though?
    i'd like it to show the whole image, online in a box of say, 300 x 300 pixels.
    i found out that anything else i try shows the image from the top left corner. so if the image in too big, u may not see the subject @ the center
  54. Simon
    Eric,

    You need to scale the image.

    Check out http://www.opensourcecf.com/imagecfc/ , this seems to the trick.

    You can reference this cfc on the action page to scale the image.

    Hope this helps
  55. Simon
    Eric,

    To adjust the allowable file size look for the line

    var maxSize = 1024 * 200;

    200 represent 200kb so to make 3mb change to:

    var maxSize = 1024 * 3000;
  56. Mathew
    Hi,

    Just wondering if there had been any update from Tadas' earlier post:
    Is it possible to return an ID or GUID via the onComplete event in the flash?

    Thanks
  57. Eric
    Simon,
    thank you for the response.
    the file size limit worked perfectly

    i'm having issues on the scaling though
    i'm pretty novice and am not sure where/how
    to reference the image.cfc i downloaded from
    the URL u posted. could you help me there?

    thnks again
  58. Simon
    Eric,

    Dont want to use Asfusion as a forum to advertise someone else but quickly just to help out.

    (if jpg use the following, if not jpg consider a similar approach as comment 44 to save other file types [although there are some issues with the code used on 44 particularly .'myform.picture = myform.id + file.type;'. Please keep in mind as far as i know flash player will only display jpg and swf dynamically [ie after runtime])

    Anyway more to the point (scaling an image to fit in a 150 width by 50 height space)

    Use the cfc on the action page.
    <!---ASfusion code--->
    <cffile action="UPLOAD" filefield="Filedata" destination="#expandpath("rawimages/.")#\#url.id#" nameconflict="OVERWRITE">
    <!---USE CFC--->
    <cfset imagecfc = createObject("component","image")>
    <!---Scale raw image and save in new location--->
    <cfset resultsx = imageCFC.scaleX("", "#ExpandPath("rawimages/.")#/#url.id#", "", 150)>
    <cfset resultsy = imageCFC.scaleY(resultsx.img, "","#ExpandPath("properimages/.")#/#url.id#", 50)>

    I hope this helps. If it doesnt check out the examples on their website otherwise leave another post. I will check back.

    Cheers

    Simon
  59. Simon
    I have been able to use the above with a cfc to scale images after upload however only jpgs scale well. Does anyone know any cfcs that scale gif and jpg well and change image type well.

    Thanks
  60. Simon
    Sorry to hog the post.

    Does anyone know how to flush the image cache.

    I dont want to save as a random number. So say i save as 1.jpg and then load another image and save as 1.jpg the old one still displays. I want the new one to always display. Thanks.
  61. Laura
    Matthew,
    No, nothing can be returned from the upload action page and that is why we used a random name that we know in advance (see that in the source).
  62. Helen
    Could someone PLEASE help me out here !?!??

    How can i add a grid next to the upload panel
    that shows the files on the
    destination folder ! (filename and size)
    AND have the grid update it's content
    with every new upload ?????

    PLEASE anyone got a clue ???

    thanxs
  63. Laura
    Helen,
    Have you taken a look that the File Explorer? http://www.asfusion.com/projects/fileexplorer/ It does what you want, although it uses Flash Remoting for that. You could also add the item to the grid contents if you don't want to use remoting.
  64. VIjay
    Hi All,

    Am working in Asp.net application, When am updating the page its properly works in Internet Explorer but not works in other browsers(Opera, Mozila).Here updates performed in the database but the page displays blank.I dono wats the reason,Please help anyone....
    Advance thanks,
    Thanks&Regards
    Vijay
  65. Joe
    I've had no problems getting the script to work. However, I'm using it within a form that is passing data to a database and having naming problems regarding the file. When a same-name file is uploaded, it is successfully renamed per the "MakeUnique" parameter in the upload.cfm file. But the value for the input on the form still holds the original name of the file uploaded. I understand cffile.serverFile is supposed to contain the new name of the uploaded file, but I'm not sure how to go about implementing it in this script.
  66. Nate
    Can you show me what the code would look like to upload and show the image after the user selects the file without them having to click a button?
  67. Kevin
    How can I get this form to submit after the image is done uploading so that the other fields in my CFFORM will submit?

    Is there a way that I can submit the form from the onComplete function? I tried it several ways and none of them were successful Truthfully, I couldn't even get the following code to work in the onComplete function:
    uploadListener.onComplete = function()
       {
          output.text = "Upload complete";
          getURL("Javascript:alert('hi')");
          uploadBtn.enabled = false;
          browseBtn.enabled = true;
       }

    why doesn't the getURL trigger? What am I doing wrong? How can I access Javascript from within the onComplete function? Is there a "submit()" function in actionscript like there is in javascript?

    Thanks a million and a half (inflation) for anybody who can give me a hand with this!
  68. Kevin
    To the moron above, maybe you should learn to read before posting questions that have already been answered!

    Oh, wait....that was me. DOH! ;)

    Sorry for neglecting the #1 rule of forum posting......and thanks to everybody who has put so much effort into helping each other out.
  69. Juan Pablo
    Hello, i have developing the site www.fotocolorcarlospaz.com.ar and i want to add the upload function to my site, but i don't have any idea about programming. Could somebody help me to insert this coldfusion code into my site to upload photos? THANKS!!! My e-mail is [email protected]
    Also, I could pay a few money for this job. THANKS TO ALL!!!
  70. Ben
    Hi,

    I see that you talked about this already in the past but i'm trying to do the _root.submitForm() that you mentioned earlier to have another page process the form fields but it's not working for me.
    I put the _root.submitForm() in the uploadListener.onComplete function and gave the cfform an action variable but alas it's not working. Would anyone have some insight as to what i should do about this?
    Thank you very much in advance.
  71. Ben
    please disregard the last post i had 2 copies of the customTag and one was over ridding the other. ::public display of ignorance....::
  72. netcru
    How do I do an AND in if loop inside your code? Im customizing some stuff there.

    the following didn't work:
    if ((condition=1) and (condition=2)) { somthing...}
    if ((condition=1) & (condition=2)) { somthing...}
    if ((condition=1) &&(condition=2)) { somthing...}
  73. Laura
    netcru,
    You mean inside the ActionScript code?
    if (condition == 1) && (condition == 2) { }
  74. netcru
    oh yeah..that works! thanks!
    Is there a way to put a progress bar for CFFTP?
  75. John
    I'm a complete novice with Action Script but was hoping to learn how to expand this a tiny bit. I have the upload working and submitting three seperate form fields using the _root.submitForm() in the uploadListener.onComplete function. I was hoping that I could validate that the form fields are not blank before I enable the Upload button. I assume that I need to modify this section of code but am not sure of the specifics and how I could separate each error condition.
    if(selectedFile.size < maxSize || maxSize == undefined)
          {
             uploadBtn.enabled = true;
             output.text = "";
          }
          else
          {
             output.text = "The file selected exceeds maximum allowed size";
             uploadBtn.enabled = false;
          }

    Any ideas if this is possible and where I should start?
  76. jhov
    Using the form I am successfully uploading a CSV over to the server. I have a seperate cfm page that contains my code to parse the file and insert the data into the database. Is there an easy way to call this file after the uploaded has been completed?

    Thanks in advance for your help!
  77. Don from DC
    I am still very confused about how I can use a hidden field to submit the name of the image file that is being uploaded. I have a bunch of fields that I am submitting to a database along with the image. I understand that the image gets uploaded first. After that, I'm lost. How and where do I put the hidden field?

    Thanks for any help.
  78. bharathi

    bharathi

    hi

    i am having problem while uploading photo
    i can upload photo,the problem is after uploading photo,it has to display the uploaded photo in another jsp.
  79. Kurt
    Does anyone have an example on how to send additional data via the query string at the same time as the upload? I would like to have fields like name and email so I know who sent the file.
  80. Kate Juliff
    I want to resize the image after upload using CFIMAGE. But I cannot see where to do that, and how to grab the filename.
  81. Kate Juliff

    Kate Juliff

    I also get the 500 error. I can only prvent it if I delete my application.cfc file, which of course isn't practical.
  82. Rene
    Hey There,

    First, your Website is genius!! I never saw anything like this before!!! Just great!

    But i have a big Problem which is discussed in this forum before, but i can't solve it anyway. I tried nearly everything.

    I talk about a Flash based upload form. Everything works fine when i install my scripts outside of a memberbased Area. But if i place it insinde, the "choose File" Button won't bring me up an window from which i can choose my file to be uploaded. i tried it with the hidden cfinput, but nuthin changes.

    I would be so glad if you guys can give me a good advise on how to handle the problem....

    Greetz René
  83. Johan
    Dear all,

    How to view my browsed image without upload it? How to get the full path?

    Thank's in advance
  84. Neo
    Hi,

    I just would like add a <cfmail> tag to send email when upload will be finishing, how to do ?
    I try to put cfmail tag on uploadListener.onComplete function, but ofcourse that dont work because we rae in actionscript and not in cfm page.

    Somebody have an idea ?

    Many thanks
    Neo
  85. FuzzySiberians
    This is great! I have couple questions. Suppose, I want to have a textarea underneath so that a user may enter image description. How can i do that? Also, is it possible to add a cfquery somewhere to save the contents in a dB table?
  86. Jason
    I have been trying to implement something like this Upload for a while with no luck.... I downloaded the files from, but all the fileUpload.swf file does is open up a blank window, I'm trying to understand what that file is supposed to do....?
    Any help on instructions on where to start with these files would be appreciated.

    Thanks in advance
  87. Jason
    cont... from previous post.....
    How does the following code link into the CFN files? I'm having trouble getting them to all work together.

    ______________
    import flash.net.FileReference;


    var imageFile:FileReference = new FileReference();

    function addListener(listener:Object):Void
    {
       imageFile.addListener(listener);
    }
    function browse(list:Array):Void
    {
       imageFile.browse(list);
    }
    function upload( path:String):Boolean
    {
       return imageFile.upload(path);
    }
    function cancel():Void
    {
       imageFile.cancel();
    }
  88. Jason
    When you download the source, are there some files that still need to be created? I'm having trouble getting the examples to work. I created a .html file to call the swf file, that doesn't do anything.
    Any help would be appreciated.
    Thanks
  89. brant
    when you are finished uploading the file. is there a way to add atributes to the pictures. aka. make the picture a drag and drop object, or add a tracking cookie to the pic?