Skip to main content
Known Participant
January 7, 2010
Question

cffile upload error enctype cf7

  • January 7, 2010
  • 1 reply
  • 1701 views

Been years since I worked with cffile and all of a sudden the rust is all over me.Done this a hunred times before ... using CF7.

Tried using cfform and cfinput instead ... what simple oversight am I missing?

I am getting the error

Invalid content type: "application/x-www-form-urlencoded"

CFFILE action="upload" requires forms to use enctype="multipart/form-data"

Uploading a .pdf to a valid path

The form page looks simple enough

            <form action="" name="add_Inv" method="post" enctype="multipart/form-data">

                      <input class="pfs" type="File" name="agmt" size="20" maxlength="100"  > 

                <input type="button" value="Apply Hdr." onClick="aplHdr(this.form)" class="whatever">

     </form>

                <cfoutput><script language="javascript">
               
                        function aplHdr(form){
                                form.action='equipment_config.cfm?page=accounting&tab=invoices&mid=#url.mid#&header=#grpfwd#';
                                form.submit();
                        }

</script></cfoutput>

<cfif isdefined('form.agmt')>

                            <cfquery name="key" datasource="#datasource#">
                                    select key_code from member
                                    where member_id=#url.m#
                            </cfquery>
               
                            <cfoutput>    <cffile
                                                action = "upload"
                                                destination = "c:\inetpub\wwwroot\*******\coldfusion\agreements\#trim(key.key_code)#"
                                                fileField = "agmt"
                                                nameConflict = "makeUnique"
                                                accept="application/doc,application/octet-stream,application/pdf,.doc,.pdf,.tmp,.txt,text/plain,.html,application/msword, image/*"
                                                ></cfoutput>

</cfif>

    This topic has been closed for replies.

    1 reply

    Inspiring
    January 7, 2010

    You need to correct the value which you have given for the "accept" attribute of your <cffile> tag,

    It should be like this,

    accept="application/msword,application/octet-stream,application/pdf,text/plain,text/html,image/jpeg"

    (You should give the exact mime type followed by a "," character).

    For additional mime types, go here,

    http://www.w3schools.com/media/media_mimeref.asp

    HTH

    Known Participant
    January 7, 2010

    Thank you for your efforts ... but that had no effect.

    Still get

    Invalid content type.  x-www-form-urlencoded

    Could it be the version of .pdf?

    on the processing end ...

    Inspiring
    January 7, 2010

    Hi,

    In that case, try adding the below mime types (for pdf) also,

    application/pdf, application/x-pdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf

    HTH