4 Replies Latest reply on Sep 28, 2013 9:57 AM by iccsi

    cffile upload

    iccsi Level 1

      I have following code to use cffile upload a file.

      I am able to upload the file from client machine to server machine.

      The only thing is after upload file, browser refresh my screen using url string without paramer like



      but my original url is



      because it change url string, the browser data refresh, no more their and it does not recognize paramter either that I can not save information to database.

      I would like to know if there is any configuration need to do or coding to make file upload keep on the same screen or I have to have a separate form to upload the file.

      Your help and information is great appreciated,






      client side code:


      <cfinput type="file" name="fleAttachment" id="filAttachment" >

        <cfinput type="submit" name="btnAttach" id="btnAttache" value="upload">

          <cfif isdefined("MyUpload")>

             file uploaded!




      here is server side code:


      <cfif isdefined("btnAttach") and isdefined("fleAttachment")>

      <cfset UploadFolder = "#application.upload_folder#" & "#form.MyParam#">


      <cfif Not DirectoryExists("#UploadFolder#")>

          <cfdirectory action = "create" directory="#UploadFolder#" />



      <cffile action="UPLOAD" filefield="fleAttachment" destination="#UploadFolder#"

      accept ="application/pdf, application/msword, application/vnd.ms-excel, text/plain"  nameconflict="MAKEUNIQUE"




      here is Application.cfc to get application upload folder.


      <cfset thisPath=ExpandPath("*.*")>

      <cfset application.upload_folder=GetDirectoryFromPath(thisPath) & "Attachment\">

        • 1. Re: cffile upload
          AnimeXCom Level 1

          You're going to have to provide more details about the flow of your pages:


          If you need to keep any URL parameters that are being passed around, you will have to attach them again and again to the URL of the form post.


          <form action="myapp.cfm?#cgi.query_string#" method="post">




          Otherwise, if you want to persist MyParam, you'll have to use a session variable to keep it persistent across pages.  Or don't even bother passing it in the url, as soon as you have the value, set it as a session variable.  You'll have to make sure you have sessionManagement=true in your application.cfc


          <cfif structKeyExists( url, 'myParam' )>

             <cfset session.myParam = url.myParam>


          1 person found this helpful
          • 2. Re: cffile upload
            iccsi Level 1

            Thanks for the information and help,


            My applicaiton.cfc has SessionMangement = True like following,



            <cfset THIS.SessionManagement = true />


            and I have set my param on the form like following


            <CFIF structKeyExists(url, "MyParam")>

            <CFSET form.MyParam= URL.Param>



            and form action like following


            <cfform action="myform.cfm" method="post"  name="frmMyForm" enctype="multipart/form-data">


            I remember it was working before, but for some reason it does not work today when I test it,

            Thanks again for helping and information,






            • 3. Re: cffile upload
              AnimeXCom Level 1

              Form and URL parameters do not persist from page request to page request unless you explcitly pass them in the URL or FORM.


              <cfform action="myform.cfm" method="post"  name="frmMyForm" enctype="multipart/form-data">

                   <!--- Pass the MyParam Value to the Next Page as a Form Variable --->

                   <input type="hidden" name="myParam" value="#url.MyParam#">


              • 4. Re: cffile upload
                iccsi Level 1

                Thanks for the information and help,

                Understand, I need set the param to the form, since cffile upload establish the form.


                Thanks again for helping and information,