Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Unable to Upload pdfs, invalid content type error

Posted on 2006-05-30
4
Medium Priority
?
684 Views
Last Modified: 2013-12-24
I want to enable staff to upload pdfs.  I have been successfully able to do this with images, but I am not having success with my pdfs.

Can someone tell me what i am missing in the upload process? I am now getting this error (i have enctype="multipart/form-data")

Error
Invalid content type: "".
CFFILE action="upload" requires forms to use enctype="multipart/form-data".

Here's my form:

<cfset request.AcceptPDF="application/pdf">                        
                  <cftry>
                        <cffile action="Upload" filefield="FileContents" destination="D:\inetpub\perlmancamp\pDocs" nameconflict="OVERWRITE" accept="#request.AcceptPDF#">
                              <cfset variables.Success="Uploaded.">      
                              <cfcatch type="Application">        
                                     <!---error. Was it a mime type failure?--->        
                                     <cfif isdefined("cfcatch.MimeType")>            
                                     <!--- yes. error message. --->            
                                           <cfif not ListContains (request.AcceptPDF,cfcatch.MimeType)>                      
                                           <h1>Not accepted!</h1>                
                                           This type of file is not allowed for upload.<br> </p>                                          
                                           <p><a href="act_pdfs.cfm">Try again... </a><br><br>
                                          </p>
                                                 <cfelse>                
                                                <cfoutput>
                                                      <b>Error</b><br>
                                                      #cfcatch.Message# #cfcatch.Detail#
                                                </cfoutput>            
                                          </cfif>        
                                    <cfelse>            
                                    <!--- Hmmm.  No mimetype error in the catch scope.
                                    Better dump out the whole error message.--->              
                                    <cfoutput>
                                    <b>Error</b><br>#cfcatch.Message#  #cfcatch.Detail#
                                    </cfoutput>        
                              </cfif>        
                                    <cfabort>      
                              </cfcatch>      
                                    <cfcatch type="Any">        
                                          <cfoutput><b>Error</b><br>#cfcatch.Message# #cfcatch.Detail#         </cfoutput>        
                                     <cfabort>      
                                    </cfcatch>      
                              </cftry>  

<table cellpadding="2" cellspacing="2">
      <tr><td class="head">Add/Modify PDFs<br><br>
      You can add, modify, or remove your pdfs with this application.</td></tr></table>

<cfif isDefined("form.title")>

<!--- put insert query here--->            

<cfquery name="insertPDF" datasource="#request.dsn#">      
INSERT INTO PPDFs
([pdfFileName], pdfTitle, startDate, endDate, submitDate)
VALUES
('#File.ServerFile#','#pdfTitle#', #CreateODBCDate(startDate)#,#CreateODBCDate(endeDate)#, GETDATE())
</cfquery>      


      
<cfoutput>
      <table cellpadding="2" cellspacing="2">
      <tr><td class="bheader">Successful Insert for PDF<br><br></td></tr>
      <tr><td class="btext">'#pdfTitle#' inserted into database.</td></tr></table>
</cfoutput>
</cfif>
                  

<table cellpadding="2" cellspacing="2" border="0">
<tr><form action="act_pdfs.cfm"  method="Post" enctype="multipart/form-data">
<td class="text">
<span class="boldtext">
Add New PDFs </span></td>
</tr>
                              <tr>
                                    <td class="text">Title</td>
                                    <td class="text">
                                    <input type="Text" name="pdfTitle">
                                    </td>
                              </tr>
                              
                              <tr>
                                    <td class="text">PDF Source</td>
                                    <td class="text">
                                    <input name="FileContents" type="FILE" size="45"><br><br>
                                    </td>
                              </tr>
                              
                              <tr><Td class="text">Start Date</Td>
                              <td class="text">
                              <input type="text" name="startDate"/></td>
                              </tr>      
                              
                                    <tr><Td class="text">End Date</Td>
                              <td class="text">
                              <input type="text" name="endDate"/></td>
                              </tr>                                          
                              
<tr><td colspan="2">
<input type="submit" value="Add PDF"> &nbsp; <input type="reset" value="Clear Form">
0
Comment
Question by:synergeticsoul
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Plucka earned 2000 total points
ID: 16795016
synergeticsoul,

Try removing the accept, then any type will be accepted.

<cffile action="Upload" filefield="FileContents" destination="D:\inetpub\perlmancamp\pDocs" nameconflict="OVERWRITE" />

Regards
Plucka
0
 

Author Comment

by:synergeticsoul
ID: 16795196
i removed it, but still get this error when I select the navigation that allows me to view this application:

Error
Invalid content type: "".
CFFILE action="upload" requires forms to use enctype="multipart/form-data".
0
 
LVL 18

Expert Comment

by:Plucka
ID: 16795409
synergeticsoul,

Ok, what you have here is correct, should work.

Are you sure that the code is as pasted, I tried it and it worked for me.

Create a dummy page test.cfm

<form action="testPost.cfm" method="Post" enctype="multipart/form-data">
    <input name="FileContents" type="FILE" size="45"/>
    <br>
    <input type="submit" value="Add PDF" />
</form>

Create testPost.cfm

with your cffile on it and see what happens.

Regards
Plucka
0
 

Author Comment

by:synergeticsoul
ID: 16797858
Thank you.  I had a database conflict, which created a problem for the whole form.

Thanks Again!!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question