Skip to main content
DharameshShrivastava
Participating Frequently
September 1, 2014
Answered

please Help me in solving this issue. i am a newbie to coldfusion

  • September 1, 2014
  • 3 replies
  • 2269 views

i want to use a single home page where i will show a form (which is in another file) to user to upload a file,after uploading (action file result) i want to show result of upload also on the same page.

these are my three files:

1. index.cfm

<!-- start -->

<html>

<head>

<title>HomePage</title>

<cfajaximport tags="CFFORM">

</head>

<body>

<cfdiv id="Main" style="width:1000px; height:600px" >

        <cfdiv id="Options" style=" width:100%;height:20%" >

            Welcome Admin, <a href="javascript:ColdFusion.navigate('FileUpload.cfm','Content')" class="settings">Update  </a><a href="#" class="logout">Logout</a>

        </cfdiv>

        <cfdiv id="Content" style=" width:100%;height:80%">

<h2>Here Goes Form and FileUploading</h2>

        </cfdiv>

</cfdiv>

</body>

</html>

<!--  -->

2.FileUpload.cfm

<!-- start -->

<html>

    <head>

        <title>

            Upload A File

        </title>

    </head>

    <body >       

<cflayout type="vbox" name="layout1">

<cflayoutarea>

    <cfform  enctype="multipart/form-data"  action="FileReceiver.cfm" >

           

                        File To Upload:

           

                        <cfinput type="file" name="Filename" size="50" >

             <br/>       

                        <cfinput type="submit" name="UploadFile" value="UPLOAD THIS FILE">

                <br/>

                  

               

        </cfform>

</cflayoutarea>

<cflayoutarea>       

    <table border="1" >

            <tr>

            <th >

                Directory Information

            </th>

            </tr>

            <tr>

                <td>

                <cfoutput >

                    CurrectDirectory Path: #getdirectoryFromPath(expandPath("index.cfm"))#

                </cfoutput>

                </td>

            </tr>

        </table>

</cflayoutarea>

</cflayout>

   

    </body>

</html>

<!-- -->

3.FileReceiver.cfm

<!---start-->

<cfif isdefined('UploadFile')  >

<cfoutput >

<cffile nameconflict="makeunique"

action="upload"

filefield="Form.Filename"

destination="#getdirectoryFromPath(expandPath("index.cfm"))#" > <!--- or destination="c:\Upload\"--->

        File upload was successful!

</cfoutput>

</cfif>

<!-- -->

when i click on "update link" index page shows the FileUpload.cfm page in one of its container but while uploading file

i always get ERROR MESSAGE:

Error retrieving markup for element cf_layoutarea736558924094373 : Invalid content type: application/x-www-form-urlencoded; charset=UTF-8. [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]

Kindly Help me doing it right...i am unable to figure out problem ...

    This topic has been closed for replies.
    Correct answer BKBK

    Ah, I found the cause of the issue: Coldfusion stores the properties of user-interface tags like cfdiv and cflayoutarea in the form scope. That is what is destroying your upload form. To see it, run the following test code:

    <cfdump var="#form#">

    <cflayout type="vbox" name="layout1">

    <cflayoutarea name="myLayoutArea123">

    <cfform >

    <cfinput type="submit" name="submit" value="Test by posting form to same page.">

    </cfform>

    </cflayoutarea>

    </cflayout>

    Now, the search for a possible solution.

    3 replies

    DharameshShrivastava
    Participating Frequently
    September 7, 2014

    thanks BKBK.

    i replaced cfform and cfinput with form and input... then i worked....

    BKBK
    Community Expert
    Community Expert
    September 7, 2014

    Thanks for sharing. Please mark it as the correct answer, so as to help someone else in future.

    BKBK
    Community Expert
    Community Expert
    September 2, 2014

    DharameshShrivastava wrote:

    <!-- start -->

    <!--  -->

    These are not Coldfusion comments. Replace them, respectively, with

    <!--- start --->

    <!---  --->

    DharameshShrivastava
    Participating Frequently
    September 2, 2014

    Okay...i kept these here only to separate codes of 3 files for better visibility...

    but what is the issue with this code, why it shows error? i am still clue less...any suggestion?

    BKBK
    Community Expert
    Community Expert
    September 2, 2014

    Suggestion after a quick browse: <cfajaximport tags="cfform,cfdiv,cflayout-tab">. Does that have any effect?

    I am looking in detail into the code.

    DharameshShrivastava
    Participating Frequently
    September 1, 2014

    Answer plz.... these are small files.... but i can not figure out exact problem/solution