Skip to main content
Inspiring
April 27, 2010
Question

CFwindow and Cffile

  • April 27, 2010
  • 1 reply
  • 2974 views

Hello,

I am having this big issue of trying to upload Images through a cffile in a CFWINDOW and I keep getting the below error

"Invalid content type: application/x-www-form-urlencoded; charset=UTF-8"

"The cffile action="upload" requires forms to use  enctype="multipart/form-data".

The cfform file is already set to "enctype="multipart/form-data".

Any one encountered this kind of problem? and what is the work around. We need to do all the uploads through a CFwindow.

    This topic has been closed for replies.

    1 reply

    umuayoAuthor
    Inspiring
    April 28, 2010

    I found a workaround, Called the page with the cffile as an Iframe inside the CFWINDOW page and that solved the problem. Could this be a bug in CFWINDOW?

    Inspiring
    April 28, 2010

    Can you post some stand-alone & self-contained code that demonstrates what you're seeing?

    --

    Adam

    Participant
    April 30, 2010

    Hello Adam,

    Use <Iframe> inside the <CFWINDOW> on the main page where its is located.

    For Example:

    (1)

    <cfwindow name="fileName" title = "fileName" height="500" width="1000" draggable="True" resizable="true" center="true" modal="true" onBindError="ColdFusion.setGlobalErrorHandler()" bodystyle="background-color: ##fffff"
        <!---refreshonshow="true" source="index.cfm?event=person.functionName"--->>
        <cfoutput>
            <IFRAME name=PO src="index.cfm?event=person.functionName" width="800" height="800" frameborder=0 scrolling=no align="center">     </IFRAME>
        </cfoutput>
    </cfwindow>

    (2)

    Now in the second Page or function [what ever you are calling] should be like this.

    <cfform enctype="multipart/form-data" method="post" >
            <p>Enter the complete path and filename of the file to upload:
            <cfinput type="file" name="FiletoUpload" size="45"  required="yes" message="Please Upload Excel File">
            </p>
            <cfinput type="submit" Name="uploadFile" Value="uploadFile">
               <cfinput type="Button" Name="uploadClose" Value="uploadClose" onClick="window.parent.myfunction();" >
         <cftry>         
            <cfif isDefined("form.uploadFile")>
               
                <cffile action="upload"
                    destination="#request.temp_excel_path#" nameConflict="overwrite"
                    fileField="Form.FiletoUpload">
                    <cfdump var="#cffile#"><cfabort>
            </cfif>
         <cfcatch>
             <cfdump var="#cfcatch.Message#"><cfabort>
         </cfcatch>
         </cftry>
    </cfform>

    This will solve the issue, but as this is converted to IFrame now, we can not use "refreshonshow="true".

    cfwindow will not refresh by it self, i am trying to find out a way.

    If you have a solution please post it . so that we can make this working perfectly fine.

    ---- Sharief Mohatad