Our Blog

As we showed in our post File Upload with ColdFusion Flash Forms, file upload is now possible with Flash 8. I introduced it with a custom tag that nicely wraps the functionality of the file upload. It is quite flexible, -hopefully- easy to use, and I believe I’ll use it whenever I need to add a file field in my flash forms. But for those of you who are curious to know how it works, or need additional functionality (which I may add to the tag in the future), this is a walk through the main functions that make it work.

p>The swf file you will find in the zip contains the libraries that make file I/O possible. In order to have those available in our flash form, we load it in a textarea. Why not use a cfformitem type=”html”? Because at the moment, that type does not have an id attribute, so we cannot reference it later.

Just so that we don’t have to escape the quotes, make a variable with the swf code:

<cfset swf = '<p><img id="upload" hspace="0" vspace="0" src="fileUpload.swf"></p>' />

<cftextarea name="textArea" disabled="true" visible="false" width="0" bind="{(textArea.html = true) ? '#swf#' : ''}" height="0"></cftextarea>

The browse button will have the following:

//a reference to the swf
var uploadSwf = textArea.label.upload;

//make an empty object that will be the upload listener

var uploadListener = {};

//we'll add uploadListener to be a listener of the file upload events triggered by our library


//we are then ready to trigger the browse action. We can pass it some parameters such as the types of file we accept, and the description of these file types

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

Our listener object can implement any of these functions, which will be called by the library after the browse has been triggered

  • onSelect(file)
  • onComplete()
  • onProgress (fileRef, bytesLoaded, bytesTotal)
  • onSecurityError(fileRef,errorString)
  • onIOError(fileRef)
  • onHTTPError(fileRef,errorNumber)
  • onCancel()

this function will be called when a file has been selected by the user.

uploadListener.onSelect = function(selectedFile){}

Inside this function, it is our opportunity to check for file size or any other property:

  • selectedFile.name
  • selectedFile.size (in bytes)
  • selectedFile.type
  • selectedFile.creationDate
  • selectedFile.modificationDate

We can also use these to show the selected file name in a text input.

onComplete will be called when the file has been uploaded

uploadListener.onComplete = function(){}

and the onProgress function is called while the file is uploaded to report progress

uploadListener.onProgress = function(fileRef, bytesLoaded, bytesTotal){}

We use that to make the progress bar and to show progress information.

Once we are set up and a file has been selected, we can call upload (most likely from an “upload” button):


We could append some variables to use in the action page.


We could also add a “Cancel” button with the following code to cancel the upload:


A live example
Download the source




  1. Michael Tyler

    Michael Tyler

    How could I reset the fileNameField value?

    Whenever i upload a file, I am able to hit upload again and it will reupload the file again, and I can keep hitting the upload button over and over, and keep uploading the same file.
    I managed to reset the text under the
    attributes.progressInfo>uploadListener.onComplete = function()


    fileNameField.text= "";

    but not the actual file value. I tried using a normal reset function, but it seems to not work.
    Tried setting the selectedFile.name=""; as well.

    any suggestions?
  2. Seth Wilcox

    Seth Wilcox

    Is there any way to get the full file path, so the image can be previewed before it is opened?
  3. Is there anyway to add aditional POST data to the url?
  4. Anonymous


    I had this problem when I was using static variables anywhere in the chain. Are you binding to static vars anywhere?
  5. Laura,

    I have been unsuccessful in reading the GET data I send along with this. Would you be kind enough to post an example or give me some direction? Thanks!
  6. William from Nigeria

    Hi guys, this is kind of off this subject. I want to know how you can use Flash and ColdFusion only (without using cfform) to upload a file. I saw an example of how flash upload can be done with php. Can anyone please tell me how to a flash upload can be done using coldfusion.

  7. Justin
    Is there a feasible way to upload multiple files (.jpg) by allowing a user to browser to a folder and upload it, but yet all file names would be intact. Basically uploading multiple files through folders.
  8. Giancarlo Gomez
    I want to completely disable the upload form and close the window I open it in after completting the upload. I love the progress bar and once the file is uploaded completely I wan't the window to close. Or at least how to disable the browse button after completion. I disabled the upload on the onCompletion function but when I try to disable the Browse button it doesn't allow.

    I did the following:

       uploadListener.onComplete = function()
       <cfif attributes.uploadButton>uploadBtn.enabled = false;</cfif>

    What can I add to disable the browse and display a close window button or automatically close the window?

  9. Justin Cook

    Justin Cook

    I am getting an HTTP 404 error. Would anyone by any chance have an idea why this would be the case? I am working on a tight development schedule and I want to use this tool, so anyone's help is much appreciated.
  10. Laura
    You would get a 404 if the upload action does not exist. In the post example, the page that receives the file and handles the upload is called &quot;upload.cfm&quot; and it's located in the same directory as the cfform. You should change it according to your own page name and directory structure.
  11. Justin Cook

    Justin Cook


    I have done that. And after the file attempts to upload and the status bar says 100% complete, I get an error right under the status bar that says &quot;HTTP 404 Error&quot;. I have double checked my file locations and naming and everything appears to be correct. Could there by any other answers?
  12. Justin Cook

    Justin Cook


    I tried moving both the upload.cfm and the flashupload.swf into the folder where my index page is at rather than moving things around like I tried to do. This took care of the 404 error, but now I get an HTTP 500 Error. Any clue on why I would get the 500 now?

    As for the 404 error, do you think moving the files solved that problem? Where in the code would one have to change in order to point to a different folder?

  13. justin


    A http:// 500 error is a server error. Your server has encountered a unexpected condition that prevents it from fulfilling the request. This is a mapping or setting issue of your files, or on ColdFusion. This should not be client side. Usually this error is not specific, so check your flog for more detail.
  14. Laura
    Justin Cook,
    404 means file not found, therefore moving your files definitely solved your problem. If you do not want to have them in the same directory, make sure you put the correct path to the upload file (I would even recommend to use absolute path, /mydir/upload.cfm)

    Regarding the 500 error, it is difficult for me to know what your problem is, but as some other person suggested, make a test.cfm file with the following code (change upload.cfm in the action attribute if your upload action page is named differently):
    <form action="upload.cfm" method="post" enctype="multipart/form-data">
    <input type="file" name="Filedata"><input type="submit" name="Upload" value="Upload">

    Run it, try to upload something and see what happens. For the most part, that is what Flash is trying to do, so you will see the same error Flash is getting and it will help you understand the problem.

    Hope that helps
  15. Steven Ross
    anyone tried this out with cflogin? I can't get it to work since the state isn't maintained in flash (I'm guessing).

    any thoughts?

  16. James Spivey

    James Spivey

    Little but simple, but im lost, is there a way to pass a variable from a query to the upload script so that once its been uploaded it will rename it to something dynamiclly stored rather than from the staticly defined variable in the cfsavecontents. I dont know how to referance variables inside javascript/actionscript. I would add it to the action page, but as you said before, there would be no way to get the filename back from the server so it needs to be passed before hand. Thanks!
  17. James Spivey

    James Spivey

    I saw that but the problem is the variable i want isnt coming from the form. Should i just add a hidden form field that will define the variable so that the script can add it that way or is thier a way to define a variable from a query and refrance it. They use "uploadSwf.upload("upload-image-action.cfm?id=" + myform.id + ".jpg");" but what if i want something like "uploadSwf.upload("upload-image-action.cfm?id=" + DUID + ".jpg");" where du id is the field name from a query. It doesnt work, so i must be doing something wrong. Is it as simple as queryname.duid? Thanks
  18. Laura
    That is a bug in the player. At least in our experience, it only happens in Firefox, not in IE.
    We have logged it during the beta but it has obviously not been fixed in the final release. I've tried appending the necessary variables (cftoken/cfid or jsessionid) but it passes "some" wrong variables that overwrite the query string. The behavior is quite strange.
    I think the best is that every person that experiences it reports it to Macromedia and maybe they will see a need to fix it.

    Yes, add the value you need into a hidden field
    <cfinput type="hidden" name="duid" value="#queryname.duid#" />
    what's important is that in order to access that hidden field you need to write theNameOfYourForm.duid

    uploadSwf.upload("upload-image-action.cfm?id=" + theNameOfYourForm.duid + ".jpg");
  19. James Spivey

    James Spivey

    Hey Laura, thanks for the prompt reply, as with all my other questions, that isnt working for some reason. I added it exactly as you have it and its just ignoring the id and uploading and naming the file "undefined" less i hardcode it into the script then it names it properly. No clue why, probably my server again (im moving servers since this one clearly isnt good, its owned by my school). My last question for you is simple, is there a way to display the file size in megs rather than bytes? Or is this to complicated to get it to code sizes below a meg? Thanks!

    Ps. Sorry to bother you so much on these snippits.
  20. Mark van Beek
    Great stuff here i keep coming back on a daily basis there is a lot to learn. My question: Is it possible to upload multiple files instead of just one?

  21. Mark,
    Yes is that possible but not in this example. We are planing to make an example when we get a chance.
  22. Steven Ross
    Thanks Laura, I didn't even consider it could be a bug in firefox. I have noticed that there are a few issues with flash and firefox (forms get out of synch with cursor &amp; cut and paste weirdness).

    I'll give it a shot with IE. Thanks again.
  23. Mark van Beek
    Thanks for your vivid response. Indeed its possible to upload multiple files. MM help reference is doing a good job here. a search for filereferenceList did the job. This is cool stuff guys.

  24. Justin Cook

    Justin Cook


    I finally got back to working on the Flash 8 upload. I tried your suggestion about trying the upload as a ColdFusion form upload, not using Flash, to see if I get the same HTTP 500 Error. I do not get that error, in fact, it uploads completely successfully.

    Would you or someone out there give me some idea why I would get the HHTP 500 Error with the flash form upload but not with the normal CFML form upload?

  25. Justin Cook

    Justin Cook

    I believe I found the cause of the HTTP 500 Error. Apparently when you specify the "accept" attribute for the MIME/Type it throws this error. Anyway to specify which file types you'll accept upon upload to make sure that someone doesn't upload a malicious file?
  26. Justin Cook

    Justin Cook

    Do you all have a way yet to upload multiple files at once? I read someone's post where they mentioned "filereferenceList", is that an answer and where can we find that?

    Also, just curious, I have up to four images that will be uploaded that will go along with a particular article. Any ideas on how I can make sure those images are related to that particular article? This is especially a problem right now for me if I have to load one image at a time.

  27. bujji
    I want a Flash File which uploads an image selected from
    local HD to a server.
    The kind that is in

    When I had downloaded the source files,they are not working for me.I don't know where the problem is.I really know nothing about Cold Fusion.
    Can you help me please..?Why the "fileUpload.swf" is not showing anything to me?

  28. Laura
    the source files should work as is. I would say that you may not have Flash Player 8. Also, does any other flash form work for you?
    fileUpload.swf does not show anything because it only contains an ActionScript library to use in the flash form.
  29. Mike Kelp

    Mike Kelp

    As an addendum, I would suggest adding a random value to the query string when refreshing the image display for replacing an image because browsers have a habit of caching.

    This way, the browser believes it is a new image address every time and doesn't show the old image.
  30. Don
    I'm still not understanding all of this. The program itself works great, ive conbined it with cfx_jpegresize, add the filenames to the dbase, everything except be able to pass another variable from the flash uploader across so at the same time I add the filenames to the dbase I also can add a comment associates with that file im uploading. Can anyone please help me on this?
  31. Laura
    You can only send variables via query string. Otherwise, submit the form for the other fields.
  32. Michael Tyler
    I have another question:
    In the browse button, you have it only lookign for image files, that is edited in the <cfsavecontent variable="browseScript"> function.

    How could I do the same thing outside of this example? I am trying to have that same function in a regular form, and I believe it is possible. Yet I cant find any info on how to make the browse dialog only show specified extensions, rather than all files.

    Any idea?
  33. Nathbot


    Hi everyone,

    as I was trying to add some actions when my upload is completed, I found a weird behavior...

    I want to add a row to a datagrid when a file is uploaded. So i have something like that:

    uploadListener.onComplete = function()
    output.text = "Upload complete";
    //here my code to add a row
    The first time it works fine.
    But if I upload another file, the onComplete function is run 2 times (I see that cause 2 rows are added to my grid). If I upload a third file, it is run 3 times, etc.

    How weird is that :)
    Have you ever seen that before?
  34. Laura
    You mean filtering the file types in a regular file upload?

    That is a known bug that we have in all the file upload examples. It happens because a new listener gets added every time the browse button is clicked. Nahuel told me that he was going to fix it, but he's been very busy... :)
  35. Neill
    If nameconflict is set to makeunique how do I retrieve the new file name?
  36. Hi Laura,

    Thanks for your reply.

    Have just changed nameconflict to skip and added a directory check and overwrite prompt to the custom tag.
  37. Steve
    Has anyone had any problems using this with Firefox? The supplied script works fine in IE but in firefox it does not place the file in the destination. It says all is ok and the file is uploaded but nothing is stored.

    Any way around this?

  38. Michael White
    Steve, I had Firefox 1.07 and couldn't make this work either so I upgraded to Firefox 1.5 and it didn't make a difference. I looked at the mozilla help site and there are few entries about flash conflicting with ActiveX but I don't know of a good way around the problem.
  39. John
    Can I get the FLA of fileUpload.swf

    Here is what I am trying to do.
    May be someone can help me with it.

    I want the same progress bar, but I am going to be uploading videos onto my website.
    After the file gets uploaded I want to convert the video into flash. And so I would like to tell the user through the progress bar, how far it is not only form being uploaded but from being converted as well.

    Let me add to this by saying if anyone know of a good way of converting AVI/MPEG/MOV into flash on the fly, right after a user uploads the video
    I'd really appreciate it.

    So far I am just calling cfexecute to call a cammand line version from geovid.

    What would be greate if you could do this through action script.
  40. Matt
    Hey John, could you help me with the command line coldfusion script with the geovid software? What is the cfexecute command supposed to look like? Have you figured out a way to convert video files to FLV using actionscript? Thanks!
  41. kevin
    ON2.com FLix Engine To encode video to flv/swf
  42. Richard Zhu

    Richard Zhu


    When I try your code at my local develop machine, it works fine but, when I put code in product server, it through 'IO Error' on me. Any idea?

  43. David
    Hi all,
    this may seem like a dumb question but i want to double check as my attempts have failed. If i had an images table my database that related to the image files, wouldn't i place the insert/update code in the upload.cfm file? i've tried this using my DAO but i just get a http 500 error. The image still updates fine, and if i take the script that updates the database to another page it processes fine, so i must be missing something within the custom tag. Any suggestions would be greatly appreciated!
    thanks again,
  44. machu
    I created an upload form for a client who needs to uplaod very larg files (~150MB) and he doesn't want to use ftp - go figure...)
    Whenever I try to upload a file that is over 100MB, I get an IOerror right after progress shows 8.5MB. I tried that with many file types and the error always happens there (between 8th and 9th MB).
    I have no problems uploading 'smaller' files (largest size I was able to upload was 85MB) - it looks like the problem exists only with files which are over 100MB!
    Is there a way around this sproblem. I spent a lot of time on this project and at this time the client refused to pay since his main requirement is not acomplished. Any help would be appreciated.
  45. MrBurns

    Anyone having issues with the &quot;Choose File&quot; button?

    I've tried the tag on two seprate installations of MX 7 on Win2003(also from to different workstations using flash 8) and still no response from clicking the &quot;Choose File&quot; button.

    Flash loads up nice and the &quot;choose file&quot; button highlights but no response after that.

    Any Ideas?
  46. Christian K.
    Is it possible to get this tag work on MX6.1 ? Thanks for any information on that. Personal offer for that deployment is ok. Thanks a lot.
  47. Zharzone

    If you read carrefully the Flash Help you will see that Flash's FileReference class limits upload to 100mb per file. So there is no workaround, I am sorry.
  48. Michael White
    I use three different Coldfusion MX 7.01 servers on Windows 2000, IIS 5. I have an application that uses Flash forms based on all the articles here since the first flash form contact application. I have used the three articles on flash form uploading to develop a file upload function that works perfectly on 2 of my 3 servers. On the actual production server the upload form does not display. when I turn on debugging the error is &quot;string literal not properly terminated&quot; and gives me 14 line numbers in the msxml file. I have patched all three servers the same (as far as I can tell) and the application files and database are identical. What could be my problem on the production server?
  49. This is my final comment on Flash Upload: It is completely pre-mature technology and I strongly suggest not using it in production environment.
    After having it in production for couple of weeks I must pull it down. Upload works great when you upload small files, but whenever you try to upload large files (up to 100MB) there is no guarantee that upload completes. I get complaints from my customers every day! - 10 to 20% uploads throws an IOerror sometime during the upload - it's ridiculous!
    When I test it, I can upload a 30MB file couple of times without a problem, but on the next try it errors out - there is no rule on when or how it happens. BTW, I tried to find any info on IOerror and how to recover from it...no luck!
  50. bswank
    Has anyone *ever* gotten this thing to work in any useful way? I see tons of posts describing bugs, problems, errors, and complex workarounds. I've spent 3 days trying to incorporate this into a real-world application and it's been nothing but a mess.
  51. Michael White
    The Short answer is Yes: I have it working in a coldfusion application at work using this code in combination with code in comments and examples to allow a user to upload a word or pdf document up to 800k in size to a special folder on the server's D: drive (outside the webroot) that saves the renamed filename to a database which I query later to download the file.
  52. Joshua Scott

    I have a question. I have the example uploading... kinda.

    When I choose a file I get "undefined" for the file name and in the details I get:

    Name: undefined
    Size: undefined bytes
    Type: undefined
    Creation Date: undefined
    Modification Date: undefined

    What am I doing wrong?

    Thanks so much for the great code.

    - Josh
  53. Joshua Scott
    While I am waiting for an answer, I have one other question.

    If I want to run another routine after the file is uploaded like... resizing the image or something. Is there a call or something I can listen for that would let me know the upload is complete and then I could call a program like alagad image or something like that to do the image resize?


  54. Laura
    I would run that right below the file upload (after cffile). Otherwise, you can also do stuff by implementing the onComplete function (see post), but in order to communicate with the server there you either have to use remoting or submit the form.
  55. Harold


    Is there a way to pass a form field to the upload.cfm page while uploading the file? I need to pass a value from a CFSELECT tag.


  56. Christian
    You might do that by a get; it´s the only way we triggered out. The fileUpload is starting a new browser-session in the background (check your session-management for that!); because of that you might give all necessary infos into a url for the get_upload.script.
  57. Christian
    sorry for my first information. You won´t get the forms posted at the same time; because of that we realized a form in flash with the selectbox inside, which we transfered by get during the file-upload.
  58. Sean
    Hi Laura,

    Just have a quick question. How would you go about uploading a file out of flash using a cfc?

    I've run into errors due to the remoting content-type being application/x-amf instead of the required octet-stream. I currently have a separate script file that does the upload. The issue is that the record is being inserted into the db within the cfc script while the file name is set to makeunique when uploaded. Of course, if the file is renamed, the cfc is not aware of this and the original file name is inserted into the record. Perhaps I should have the upload script query the same table using @@Identity and comparing the server file name with what is in the table.

    The web site I listed along with the post is the app I'm working on. If you check it out go to 'candidate registry' and click 'register' on the next screen.

    Thanks so much for any tips!
  59. Laura
    See my replies:

    The upload is done via a form POST (done by the Player), so it is not via Remoting (amf). When you do the upload (say it is upload.cfm), you can do other things there, such as calling a CFC that does some processing. We've done that in the Flex version of the real estate application. In that case, we resize the image, but you could insert things in the database or do whatever you want to do. Although it is not the best solution, it is the only way of doing with the current implementation of the upload in the Flash Player.
  60. Michael White

    Michael White

    I have all this working great on my development web server but the production webserver has a security requirement that I have to use a certificate and the protocol has to be https:// (encrypted). I have found out today that I cannot upload unless I use http:// is there an easy (or any) way to fix this?
  61. del
    Hi all,
    I using filereference with PHP and asp.net. With PHP, working very fine. In asp.net, locally working fine but on deplyoment server, itz behaviour becomes bull shit. The same file gives, 500 error or io error. post data size and upload size on server is enough but....BUT....dz anyone help?
  62. Michael White

    Michael White

    Thank you very much for the reply and link, Laura. I have a line that looks like this:
       uploadSwf.upload("https://jobs.lansg.com:443/HR/ResumeUploadAction.cfm?resume="; + myform.ContactID + myform.FileExtension);

    I get no errors but I get no file either.
    the link you supplied me was helpful but I don't know anything about implementing crossdomain.xml or the loadpolicyFile he talked about: I got a 404 error browsing to it. Can you give me pointers on how to use this info? (System.security.loadPolicyFile('https://flexdemos.cynergysystems.com/support/crossdomain.xml');)
  63. Laura
    Nevermind about the semicolon, I think it got there because of the automatic linking.
  64. Rt
    I am trying to get the file upload in flash working.It works only for some types of file extensions like .txt,doc,.xml but when i select an image or a file with extesion .xls,the filesize is returned as zero and as a result the upload script never gets called.
    Any help would be greatly appreciated
    Thank u so much
  65. Laura
    Can't really help you with the info you give. Are you sure it doesn't upload "any" image? Maybe the directory is not accessible, I don't know. Also check what extensions you are allowing in the code.
  66. Ness
    Hi, im so new in this, and i have a question, maybe will be stupid, why the files have the extension "CFM" do i have to install something on my server to make it work? the server must have that service. ThanKs, im sorry for taking ur time. really sorry
  67. Angel
    Hi i got it to upload pictures fine, but when it finishes uploading the file i need to <cflocation url=""> out of there to another page i did this doesnt work

    <cfif attributes.progressInfo>uploadListener.onComplete = function()
    output.text = "Upload complete";
    "<CFLOCATION URL="anotherpage.cfm">";
    <cfif len(onComplete)>#onComplete#();</cfif>

    Any ideas?
    i also tried this
    <SCRIPT language="JavaScript"> top.location.replace("http://www.yahoo.com";);</SCRIPT>
  68. Angel
    Hi still having trouble cflocationing out of there once the image is uploaded if anybody could copy paste some code i'd appreciate it.
  69. Laura
    It's ColdFusion code (.cfm file extension), therefore, your server needs to have ColdFusion 7.01 or above to make it work.

    I think you are mixing up the code of the custom tag with this code. If you use the code in this post, create an onComplete function (you can't use CF or javascript inside ActionScript code):
    uploadListener.onComplete = function(){
    _root.getURL('address where you want to go');
  70. Kevin Jason
    Hi Laura -

    Similar to others, I have come across an "IO Error" issue when using the file upload from different work stations. The odd thing is, I'm using the same browser, files, and code...but run into the "IO Error" on some work stations and not others. The file sizes are all less than 2-3KB. Is there some file or files that are needed that may not be downloading properly to certain workstations? (I'm out of other ideas)

    Thanks in advance,

  71. Keiko
    Hi Laura,

    I have 2 pages (page1.cfm and page2.cfm). I put your fileupload component and a submit button in my first page. But I want the uploading take place only when it hits my second page (after I click the submit button). How to do about that? In your example, you call the uploading function when user click a button with onClick event in the first page.

    Looking forward for your reply.

    Thanks in advance
  72. Zeus
    Hi everyone,
    I apologize for bringing problems and not solutions to this thread. I am working with a flash multiple-file uploader with a PHP server-side script. I can upload one large file (over 80 MB) or multiple small files ( less than 2.5 MB) with no problems. The problem comes when I upload two or more large files (over 8 MB). When I invoke the upload function, the computer freezes (actually freezes even the mouse) for about 10 min, then it would resume its operation and the upload process fails with this message “flash script running slow, computer might become unresponsive”. I have tried other flash uploaders found on the web, even the example in the Flash 8 help files, but I run into the same problem with multiple large files. Anybody ran into this problem before? Can anyone shed some light on this issue? Help is very much appreciated.

  73. chris
    Hi Laura,

    I am having a problem using this with security on my site... It seems that if the upload.cfm page contains the below code the application makes it look like it is moving the file (the progress bar goes) but the file does not move... Any thoughts? THANKS! GREAT AP

    <cfif NOT isdefined ("form.emp_usn") OR NOT isdefined ("form.emp_pwd") OR NOT structkeyexists(form,"Filedata")>
    <cfif not IsDefined ("Session.authenticated")>         <cfinclude template="/loginform.cfm">
  74. myname
    Does anyone know how to do this with PHP?
    Having Trouble.
    Someone mentioned they had an example of how to do it.
  75. George
    I have the upload working fine. I have a grid and some fields to go with it. So an item in the grid gets selected and the fields get filled in with data. How can I have the cf-flashupload show the data like the other fields?
  76. Laura
    Unfortunately, in the upload action file, you only receive "Filedata" and no other field (see my comments on passing url variables as a workaround), so you cannot check for form.emp_usn for example. Neither you will achieve anything by cfincluding the login form since the upload happens "in the background". You will see the file uploading, but CF will not do anything with that data, since you have that <cfif>.

    See my comment above: http://www.asfusion.com/blog/entry/file-upload-explained-and-expanded#comment-889

    If I understand your question correctly, you want to bind the grid data to the field? If so, the field that shows the file name is just an input field, you can use your regular binding. (Now that doesn't mean you will be able to upload anything that gets shown there, it's just a string in a text input at that point)
  77. George
    You are correct in what I am asking.
    I did try and bind like:
    <cf_flashUpload name=ImageBottle actionfile="Upload" fileTypes="*.jpg" bind="{ProdList.selectedItem.ImageBottle}">
    Im thinking this should show the name of the image that is being used. Its perfect that it wouldnt upload that then. I just want the user to see what image is attached to the rest of the data. Then make the decision to select a new image or just edit some of the text and update that. leaving the old image or changed to a new one. But I cant get the bind to show the file name in the input of the upload. Is my statement wrong?
  78. George Smith
    Your the best! I have all working perfect.
    20 form fields 8 browse fields (bound to my grid), Add, Edit, Delete. So Great!
  79. Laurent


    Laura, Michael,
    It seems I experience a problem about uploads over SSL on Firefox. I've tried many combinations of the cross-domain file and still have I/O error. On IE everything is OK... Have you found something that could help me ?
    Thanks for your answers
  80. js
    I had a problem with uploads working in IE but not Firefox. It turned out that I had to do this:

    In Firefox it creates a new session when it goes to yourUploadFile.cfm, but in IE it preserves your current session. Hope this helps.
  81. Todd
    This form work great on my development server which uses the standalone cold fusion web server, but on my production box which uses IIS 6.0, cold fusion 7.02, and active directory for authentication I am having some problems. When I try to upload a file on the production box I am able to select a file and begin the upload. The status works and shows the file being uploaded up to 100%. Once it reaches 100% I am asked to login again to active directory. The file is never uploaded and if I try to close the browser (IE7 and Firefox) both freeze.

    I can get a file upload to work using (this one works):
    <cfif isdefined("form.upload_now")>

    <cffile action="upload" filefield="ul_path" destination= "uploadspot" nameconflict="makeunique" variable="FileName">
    <cfdump var="form">

    <cfform method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
    File Name: <cfinput type="text" name="FileName" id="FileName" size="150" width="100" required="yes">
    <cfinput type="file" name="ul_path" id="ul_path">
    <cfinput type="submit" name="upload_now" value="submit">

    I am guessing this is a security issue but I am not sure where to look (IIS or Cold fusion)

    Thanks in advance
  82. Bacardi


    For those asking about post data. Here is my crazy work around. The page refreshes, but it is still a fluid form layout with practical use. The URL string max's out at 255 characters and i am capturing comments that can be 400 char's.

    I needed a form that captured user info along with photo.

    In the upload script, check for the value of fileNameField, if it is empty, make a custom function call

    var fileNameField = fileNameField;

    if (fileNameField.text == '') {

    _root.getURL("uploadNoPic.cfm?postData=" + myForm.postData,"_parent","POST" );

    else {
       var uploadSwf = textArea.label.upload;
       uploadSwf.upload("upload.cfm?userid=" + myForm.userid);
       uploadBtn.enabled = false;
       browseBtn.enabled = false;

    At the bottom of the uploadListner.onComplete function add another getURL call such as:

    uploadListener.onComplete = function()
    var userid = myForm.userid;
    output.text = "Profile Saved.";
    uploadBtn.enabled = false;
    browseBtn.enabled = true;
    _root.getURL("completeUpload.cfm?photo_name=" + myForm.fileNameField + "&userid=" + myForm.userid + "&postData=" + myForm.postData,"_parent","POST")

    I did need to reference the file uploaded with the data posted later and that was done using a temp table in the db and a hidden field on the form.

    The initial upload saves the picture and writes file name and user identifier that is stored in the session as a record in the temp table.

    The getURL call in the complete function calls an action page that queries the temp table for the filename and user id match.
    Then inserts into actual table the complete record with post data, photo name, and userid. It then deletes the temp record and cflocation redirects.

    Pretty off the wall hack, but it works for the time being.

  83. Bacardi


    Hi all,

    Has anyone figured out the rhyme or reason behing the IOError?
    Sometimes I get them and sometimes I don't and I haven't been able to identify any one thing that I'm doing differently from one upload to the next.


  84. Rod
    Ok Getting the 404 error issue... here's the scenario.

    I have a fuse box application. Multiple tab navigation flash form. the code i am using is strait forward.

    <cfformitem type="text" style="fontWeight:bold">upload</cfformitem>
    <cf_flashUpload name="defaultFile" actionFile="user/upload.cfm" swf="user/fileUpload.swf">
    <cf_flashUploadInput />

    The uploader brings up the dialog box and locates the file fine, but when submitted I get the 404 error. I have read every post on this issue and tried every option I can think of.

    1. Placing the upload.cfm file in the root directory of the fuseapp next to the index file.
    2. placing the upload file in the parsed directory (just thought i would try.
    3. using /user/upload.cfm
    4. using user/upload.cfm
    5. upload.cfm

    I even took the full example folder that i downloaded from you and tried it as it was (that worked fine) so i know it is not your issue, but i am not getting it to find the upload file.

    Any help would be greatly appreciated!
  85. stuart
    Here's an example of one of our websites in which file upload is used successfully so users can each have their own image library's www.myheadspace.org/flash : I carry additional data into the session by first pre-flighting the image, i.e. doing a POST that tells the back-end to expect an image and places a row in the database for it with any extra data i send, this returns the DB row id back to flash that then appends this onto the end of the 'upload' GET string, thus linking the image to that user/session. Any messages during upload or image verification after upload are stored in a db table under the same id, so after the upload is complete flash checks the table for its message of either 'upload commplete' or whatever error there was i.e. 'wrong filetype' 'file too big' etc. You'll have to register with the site to try it and then try uploading files in your profile where you can re-size them, move them etc.
  86. sandro


    I upload correctly a file but i want store also kb dimension in a database table.
    How i can do it ?
  87. Dave
    I'm new to just about everything - coldfusion, flash and actionscript. I done a little bit of coldfusion programming and have some background in Perl. I need to be able to post the filename (and file size) of the file that's selected to a database. How can one get the value of the selected filename from the actionscript/flash code out to a coldfusion variable? A sample of how this is done would be greatly appreciated. I know this was asked before but I didn't see any code that illustrated how this was done.

  88. Don
    Any intranet security issues with using this fileupload? The progress bar instantly goes to 100%, then I get prompted for a network login. The file does not upload at all.

    Upload.cfm works fine with a ColdFusion/html form, but not this flash form. There is no login prompt.

    What would cause it to go immediately to 100% progress bar and require login?

  89. kalai

    I've an issue. I've a flash uploader to upload multiple files(pdf, doc) to a folder in the server.The upload is working fine. I want to download the files to my desktop using the core ftp. But, I see the permission of the folder as 600 and I cannot download them to my pc either. So what's wrong and how to fix it??
  90. Lance
    I am having the same problem as MrBurns. The Choose File button works fine by itself in the example code, but when I try to implement that same code into an existing application, it does not work.

    The app is a Fusebox application, but that really shouldn't matter. I have spent a lot of time on this and still nothing. Other events on the button work, such as GetURL(), etc.--just not the browseScript. Someone please help if you have an answer!

    Thanks in advance.
  91. Manuel Roque de Jesus
    Hallo, very ood work,
    i try to use your source, but my browser brings always the error "lc_id" is undefined on line 26 ???
    any idea what this mean?

    Thanks in advance.
  92. Laura
    Sandro, Dave,
    See documentation on cffile action="upload". You will get the uploaded file name, size, etc, such as cffile.fileSize You'll get that information in the upload.cfm file right after using cffile for uploading.

    Authentication does not work with flash upload. If you use browser prompting authentication, flash upload does not support it. I don't think you use some kind of redirection to a login form, but that doesn't work either, since flash calls this file in the background.

    Make sure the path to the upload swf file can be loaded. Use absolute paths when in doubt (ie: /myassets/fileUpload.swf)

    See this:
  93. Don Kerr

    Don Kerr

    Laura, Thanks for your reply on the authentication issue. Let me back up a step and ask How should security be setup to get file upload to work? Is it a Windows folder permissions issue?
    If I know what it takes to make it work, then I can change my security setup accordingly. I'd appreciate any further assistance.

  94. Andy
    Hi Laura,

    I'm very impressed with the content of this blog. I have a question about the FileReference.upload() method that I haven't been able to get solved anywhere else. I have a Flash application that allows users to upload images and manipulate them online. It works perfectly fine for anyone running a PC, but all Macintosh users get an HTTP 404 error (caught by fileReference.onHTTPError) when they attempt to upload an image. The same situation occurs with Mac users running Safari, IE, and Firefox.

    I have tried the following fixes so far, with the same result every time:

    --I used the run the upload across domains, but now I have it set up under the same domain as the upload script which receives the upload request.
    --I have tried adding a crossdomain.xml file which allows requests from "*" (even though I am no longer sending the request across domains)
    --I have tried referencing the upload script relatively and absolutely, and I have tried including the port in the domain name of the upload URL.

    Do you know of anything else I can try? I am out of ideas. Using the onProgress method, I have confirmed that the upload does not proceed at all (stays at 0%). I know the URL to the script is correct though, since everything works fine when running on a PC.

    Thanks Laura for your thoughts. Best,

  95. Lance
    Make sure the path to the upload swf file can be loaded. Use absolute paths when in doubt (ie: /myassets/fileUpload.swf)

    Laura--that was it. It was a pathing issue. Make sure the reference(s) to the .swf file are correct, or things will get screwy! Thanks so much!
  96. CJ Lazell

    CJ Lazell

    Trying to do what this previous post said but there has been no reply of yet.


    44. John wrote on January 23, 2006 at 5:46 PM
    Can I get the FLA of fileUpload.swf

    Here is what I am trying to do.
    May be someone can help me with it.

    I want the same progress bar, but I am going to be uploading videos onto my website.
    After the file gets uploaded I want to convert the video into flash. And so I would like to tell the user through the progress bar, how far it is not only form being uploaded but from being converted as well.

    Let me add to this by saying if anyone know of a good way of converting AVI/MPEG/MOV into flash on the fly, right after a user uploads the video
    I'd really appreciate it.

    So far I am just calling cfexecute to call a cammand line version from geovid.

    What would be greate if you could do this through action script.
  97. CJ Lazell

    CJ Lazell

    Just read that first post back and it's terrible. Sorry about that you can delete it. I'll start again. I basically need the same progress bar from the flash upload form for my <cfexecute> cmd. To show the progress of the conversion to flash. If you could help out that would be great! :)
  98. Meghan


    I've looked through the comments to see if someone else brought up this behavior, but didn't see anything. I've been using file upload successfully on a production application. Today a user told me that when he attempted to choose a linked file to upload, it uploaded the actual .lnk file rather than the file it was linking to.

    I know that my non-Flash CF file uploads in the past haven't had this problem. Is this a known issue or am I just missing something here?
  99. Micho
    Hi, im using this component on my own way, but when i reset the form with function (resetForm) the textarea lost binding and component file works no more. what can i do, for avoid this problem, and of course i need to reset my form

  100. Nicolas


    Is there any way to resume a broken upload?
  101. Greg
    i'm trying to add an input query after an image file is uploaded... any help would be appreciated.

    what i've tried so far:
    in upload.cfm
    i've tried to ride in on the cfif by adding my cfquery
       <cfquery name="Filedata" datasource="bido">

       insert into Images (
       Values (
    nothing fancy, but i wanted to use this file upload as the engine to put photos up in a private gallery i'm building.

    http://gcm.syr.edu/bido login with t2h/t2h

  102. Greg
    found my own answer - ironically from something i wrote last year... guess the memory is going.
    nice site - i wonder why no one posts/maintain it consistantly? actually it's one of the better forum sites i've seen.
    btw, the answer was: <cfset MakeUpVarNameHere = "#FILE.ServerFile#" /> in case anyone else has this problem.
  103. Cn
    Hi Laura
    From this example, it work very good.
    I also want to save the file name into Access database, but some how I can't able to make it work.
    I need the file name display in the input field, how that work.
    please advise, very appreciate.
  104. Cn
    Hi Laura
    From this example, it work very good.
    I also want to save the file name into Access database, but some how I can't able to make it work.
    I need the file name display in the input field, how that work.
    please advise, very appreciate.
  105. Dave
    I am having trouble assigning a dynamic path to the upload destination location. Does anyone have a clue how to get a dynamic path passed to the upload.cfm file. Below is my upload form:

    <cfset position = #ArrayLen(session.newproject.items)#>

    <cfif DirectoryExists(expandpath("/UploadedFiles/#session.newproject.ProjectID#"))>
       <cfif DirectoryExists(expandpath("/UploadedFiles/#session.newproject.ProjectID#/#session.newproject.items[position].ItemID#"))>
          <!--- Nothing happens here if it exists--->
          <cfset temp1 = expandpath("/UploadedFiles/#session.newproject.ProjectID#/#session.newproject.items[position].ItemID#")>
          <cfdirectory action="create" directory="#variables.temp1#">
       <cfset temp = expandpath("/UploadedFiles/#session.newproject.ProjectID#")>
       <cfdirectory action="create" directory="#variables.temp#">
       <cfset temp1 = expandpath("/UploadedFiles/#session.newproject.ProjectID#/#session.newproject.items[position].ItemID#")>
       <cfdirectory action="create" directory="#variables.temp1#">

    <cfform name="myform" width="420" format="Flash" timeout="100" skin="halosilver" action="index.cfm?NewProject=DocInfo">
       <cfformgroup type="panel" label="File Upload">
          <cf_flashUpload name="defaultFile" actionFile="upload.cfm">
             <cf_flashUploadInput progressBar="true" progressBarStyle="#progressBarStyle#"/>
       <cfinput name="submit" type="submit" value="Done Uploading Files">

    This code creates the folder and subfolder where I want the files to be uploaded.

    What I need now is to figure out how to pass the path this file creates to the upload.cfm file. If anyone could guide me to the light it would be gratefully appreciated.

  106. Jamie
    I am using this uploader

    and it works great on my local host, I upload it to my identical server (both local, and Server are CF7)

    It works perfect on Localhost, but when I try to load the uploader on the server I get

    Error: lc_id is undefined

    This is the executed source

    <script type="text/javascript" charset='utf-8'>
    document.write("<object id='myform' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,14,0' width='420' height='200'> ");
    document.write(" <param name='src' value='/NEWTEMP_DELETE/MEMBERS/1090207516.mxml.cfswf'/>");
    document.write(" <param name='wMode' value='Window'/>");
    document.write(" <param name='flashVars' value='historyUrl=%2FCFIDE%2Fscripts%2Fcfformhistory%2Ecfm%3F&lconid=" + lc_id +"&%5F%5Fmyform%5Fcacheid=39AD13B7%2D13D3%2D9F41%2D4C8230958E6B1FD2'/>");
    <script type="text/javascript" charset='utf-8'>
    document.write("<br><iframe src='/CFIDE/scripts/cfformhistory.cfm' name='_history' frameborder='0' scrolling='no' width='22' height='0'></iframe></br>");

    Can someone tell me why this might be happening thanks
  107. David
    Why is there a 200mb file upload limit? Is this a property of Flash? I assure you I have every threshold open to the max on my cf server, web server and flash params. I have used both Windows and Linux, and the problem is the same on both. Thanks for any insights. I need an uploader that can do more than 200mb!
  108. David
    Nevermind, I missing the "Request Throttle Memory" parameter. It was set to 200mb. Duh. That's what I get for working late at night. However, there are still times when a file is being uploaded and will randomly get an IO error, but that seems independent of the file size at this point. Sorry!
  109. Joe
    When implementing the upload with a cancel button. The cancel button does not work with Firefox (it works in IE). I have noticed the same with your example page.

    Is there any known issue or workaround for this?

  110. Kirsten



    I'm confused about where to add my database code (SQL). My files upload file into the folder, but after the upload I want to add a record to my database. I put it in the upload.cfm file, inside and outside that cfif statement. It just doesn't DO anything. No errors or new rows in the DB.

    Does anyone know how/where to do this? Is there something funky I have to do to my code?

  111. EDGAR
    File upload works great. What do I need to add to insert image file name into a database. I know how to accomplish this with a cfform.
  112. Jim Thirlwell

    Jim Thirlwell

    I'm running the code from http://www.asfusion.com/examples/item/file-upload-explained on both my dev machine and remote server. Everything works fine, except for the "Cancel Upload". Has anyone had a similar problem with this code, and if so did you find a solution?

    I'm using CF8 on both dev machine and remote server if that matters.

    Thanks in advance.
  113. Sandra

    Has anyone figured out a workaround for passing form fields to the upload.cfm page? I read that is not possible but those posts are from 2006. Just wondering if there's a workaround now.

  114. Sci-Fi-Si
    Sweet bit of programming, very elegant.

    Plus! I still have hair. I need to add the file name to MySQL but I think?? I can handle that.

    Thanks again.
  115. Natalie


    I was having trouble creating a form that would submit to a database as well as upload multiple photos if any were selected. I think I finally have a solution, so I thought I'd post it here in case it helps anyone else.

    <cfform format = "flash">
    <cftextarea name="ItemDesc" height="250" width="300" label="Description" required="yes" message="Please enter a description."/>

    <!-- PHOTOS -->
    <cf_flashUpload name="Photo1" actionFile="upload.cfm" label="Photo 1:">
    <cf_flashUploadInput uploadButton="false" required="false" progressBar="false" />

    <cf_flashUpload name="Photo2" actionFile="upload.cfm" label="Photo 2:">
    <cf_flashUploadInput uploadButton="false" required="false" progressBar="false" />

    <cfinput type="Button" name="PhotoButton" onclick="#Photo1_uploadScript##Photo2_uploadScript#_root.submitForm();" value="Submit"/>

  116. Natalie


    I was having trouble creating a form that would submit to a database as well as upload multiple photos if any were selected. I think I finally have a solution, so I thought I'd post it here in case it helps anyone else.

    <cfform format = "flash">
    <cftextarea name="ItemDesc" height="250" width="300" label="Description" required="yes" message="Please enter a description."/>

    <!-- PHOTOS -->
    <cf_flashUpload name="Photo1" actionFile="upload.cfm" label="Photo 1:">
    <cf_flashUploadInput uploadButton="false" required="false" progressBar="false" />

    <cf_flashUpload name="Photo2" actionFile="upload.cfm" label="Photo 2:">
    <cf_flashUploadInput uploadButton="false" required="false" progressBar="false" />

    <cfinput type="Button" name="PhotoButton" onclick="#Photo1_uploadScript##Photo2_uploadScript#_root.submitForm();" value="Submit"/>

  117. David
    Everybody here should take a look at the Yahoo Uploader component they offer, which comes with full documentation and API support: http://developer.yahoo.com/yui/uploader/ The entire YUI library is just a gold mine.

    The component uses Flash in the background to do the actual file uploading (they provide the action script source too), but uses Ajax for everything else related to display so you can use divs and totally customize the look-and-feel and all other functions.

    Their advanced example show how to implement progress bars. The Flickr Uploader is based on this. You will want to look at the "Connection Manager" component to integrate the upload with calls to your server...I am using it with ColdFusion on the backend, and you can send as must POST data as you want. It's all standard Ajax. Most of these third-party Flash uploaders are based on the exact same concept.

    Yes, you have to be a real coder to understand and customize it, but you will feel much more empowered, and frankly this is a much more sophisticated way to go about it these days. There is a Yahoo Group that supports it and everything.

    I have been in uploader hell for a while dealing with most of these pre-packaged Flash apps, but the YUI components have set me free. The world is once again my oyster.

    One final note: I did obsessive research on file upload limitations via HTTP, and there is a 2Gb brick wall...period. It has to do with Flash being a 32-bit program. Doesn't matter if you are running a 64-bit server, it is a client issue. Same goes for web browsers. You cannot upload a file larger than 2Gb through a browser regardless of the front- or back-end technology you are using. Sadly, we will have to wait for 64-bit PCs to hit the mainstream before this problem goes away.

    That being said, there is a sneaky way around this by using a Java applet with file splitting (aka "chunking") built-in. If you Google it there are a couple apps that look worthy. Yes, you have to develop the workflow on your backend for dealing with split files once they are transmitted to your server (the Java app on the client actually does the splitting before sending to your server), but it's worth it if you ever want to upload more than 2Gb.

    I hope this helps. This stuff is constantly evolving.
  118. Fred
    Has the listener gets added every time the browse button is clicked bug been fixed or is their a work-around?


    ()38. Laura wrote on November 23, 2005 at 8:00 PM
    You mean filtering the file types in a regular file upload?

    That is a known bug that we have in all the file upload examples. It happens because a new listener gets added every time the browse button is clicked. Nahuel told me that he was going to fix it, but he's been very busy... :)
  119. Stephen


    Laura, I know this is probably relatively simple but I am new to CF so forgive me. From what I understand; all you have to do is download your example throw it on the server and it's supposed to work. I try to do this and I get a blank screen when browsing to the example page. Can you offer some suggestions on what might be going on? Maybe I have some configuration issue?
  120. Randy Johnson
    I have a weird issue. I used this code behind a session based login. The script works fine if I turn off the login code, but if I turn on the login code and login to the website, the flash communicating with the server does not recognize that I am logged in and the upload does not work. Has anyone else experienced this? I could put a hidden username and password in the form so if anyone hit the upload from outside of the page it would not execute and check the referrer, but it would be nice if I could figure out a better solution.

  121. Jim
    When the file uploads - I want an email to be sent to me telling something was uploaded. AND I would like a text box to show after the file uploads so the user can type a message and hit SUBMIT. BUT I need the email confirmation of a file uploaded even if they don't type anything into the text box. Been working on this and just can't get it to work. Any help would be greatly APPRECIATED!!!!!!
  122. Serg
    To Randy Johnson

    The Flash Player doesn't send browser cookie(session cookie) for non-IE browsers. Some of other flash upload controls retrieve cookie via JavaScript(document.cookie) and send it as a form field value(http://www.easyalgo.com/eaflashupload.aspx; MultiPowUpload). But it is non complete solution, because session cookie is set usually with "HttpOnly" flag and due to this reason cookie is not available via JavaScript. You may store SID on the page inside hidden form field.
  123. Rob
    Hi there,

    Wondering if there is any plans to update this (or the other flash form upload examples) to work with firefox. It's perfect in IE, but in firefox it just looks like it worked, then the file never shows up. Thanks!
  124. mcm
    is there going to be an update to this component? specifically to address the issues with flash 10
  125. Chris
    The onComplete doesn't seem to work correctly in Chrome.

    appears to cause /some/page to be loaded in a frame within the flash object. In Firefox and IE, it correctly causes the browser, not flash, to load the page.