Posted on 2012-08-22
Last Modified: 2012-08-22
No matter what I do, I can't seem to locate the error that's causing this.  I commented out the DIV set where the form resides in case it was creating an issue with the error, but still keep getting the same error. I've spent nearly 3 hours combing through my code and still no resolve.


Invalid content type: ''.  
The cffile action="upload" requires forms to use enctype="multipart/form-data".  
The error occurred in C:\domains\restorationlutherancom\admin\photo_uploads.cfm: line 31
29 :   <cffile action="upload"
30 :      fileField="ifile"
31 :      destination="C:\domains\restorationlutheran\images\tempUpload\" nameconflict="makeunique" accept="image/jpeg">
32 :             <cfif cffile.filesize gt 200 * 1024>
33 :         <cffile action="delete" file="C:\domains\restorationlutheran\images\tempUpload\#cffile.serverfile#">

<cfparam name="url.area" default="home_slides">
<cfparam name="url.imgid" default="">
<cfparam name="form.area" default="#url.area#">
<cfparam name="form.ifile" default="">
<cfparam name="err1" default="">
<cfparam name="c1" default="">
<cfif url.area is "home_slides">
<cfset idesc="JPG Format - 72dpi, 850px wide by 233px tall">
<cfdirectory action="list" directory="c:\domains\restorationlutherancom\images\user\rot\" sort="asc" name="il" filter="*.jpg">
<cfset ip="/images/user/rot/">
<cfset cip="\images\user\rot\">
<cfset sti=1>
<cfelseif url.area is "home_buttons">
<cfset idesc="JPG format - 72dpi, 240px wide by 180px tall">
<cfdirectory action="list" directory="c:\domains\restorationlutherancom\images\buttons\" sort="asc" name="il" filter="*.jpg">
<cfset ip="/images/buttons/">
<cfset cip="\images\buttons\">
<cfset sti=1>
<cfelseif url.area is "article">
<cfset idesc="JPEG format - 72dpi, 240px wide by 180px tall">
<cfdirectory action="list" directory="c:\domains\restorationlutherancom\images\articles\" sort="asc" name="il" filter="*.jpg">
<cfset ip="/images/articles/">
<cfset cip="\images\articles\">
<cfset sti=0>
<cfparam name="idesc" default="">

<cfif isDefined("ifile")>
  <cffile action="upload"
     destination="C:\domains\restorationlutheran\images\tempUpload\" nameconflict="makeunique" accept="image/jpeg">
		<cfif cffile.filesize gt 200 * 1024>
        <cffile action="delete" file="C:\domains\restorationlutheran\images\tempUpload\#cffile.serverfile#">
        <cfset err1="The file you uploaded exceeded 150kb. Please ensure the file meets the upload requirements.">
        <cfset c1="The file was uploaded.">
<!doctype html>
<html  lang="en">
  <meta charset="utf-8">
 <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
<title>RLC - Admin - Photo Upload Page</title>
<!--- <script src="includes/SpryCollapsiblePanel.js" type="text/javascript"></script>
<link href="includes/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" /> --->
<link href="" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  if (restore) selObj.selectedIndex=0;


<!--- <div id="CollapsiblePanel1" class="CollapsiblePanel">
  <div class="CollapsiblePanelTab" tabindex="0"><h1>IMAGE ADMIN PAGE</h1></div>
  <div class="CollapsiblePanelContent"> --->
<FORM method="post" enctype="multipart/form-data">  
  <table width="100%" border="0" cellspacing="0" cellpadding="3" class="black12">
    <td width="14%" align="right" bgcolor="#CCCCCC">Select Area of Site:</td>
    <td colspan="2" bgcolor="#CCCCCC">
      <select name="area" id="area" onchange="MM_jumpMenu('parent',this,0)">
        <option value=""<cfif url.area is "home_slides"> selected="selected"</cfif>>Home Slideshow</option>
        <option value=""<cfif url.area is "home_buttons"> selected="selected"</cfif>>Home Buttons</option>
        <option value=""<cfif url.area is "article"> selected="selected"</cfif>>Article Image</option>
      </select><CFOUTPUT>* #idesc#</CFOUTPUT></td>
    <td align="right" valign="top">Existing Images:<br>
      <hr /><cfif sti is 1>Please select an image to replace<cfelse>Please upload a new image according to the specifications listed for this area of the site. If the image you want is already displayed to the right, there is no need to duplicate the upload. Please use the ARTICLE ADMIN PAGE to select that image for your article.</cfif>
    <td colspan="2"><div id="uploaded_images"><cfif il.recordcount gt 0><cfoutput query="il"><a href=""><img src=",400)#" class="thumbs"  <cfif url.imgid is "#ip##name#">style="border:4px red solid"</cfif>/></a></cfoutput><cfelse><h2>THERE ARE NO IMAGES TO DISPLAY AT THIS TIME</h2></cfif></div>
<cfif form.ifile is "" AND err1 is "">
    <td align="right" nowrap="nowrap" bgcolor="#CCCCCC">Select File to Be Uploaded:</td>
    <td width="36%" bgcolor="#CCCCCC">
      <input type="file" name="ifile" id="ifile" /></td>
    <td width="50%" bgcolor="#CCCCCC">&nbsp;</td>
<cfelseif not err1 is "">
    <td align="right" nowrap="nowrap" bgcolor="#CCCCCC">Select File to Be Uploaded:</td>
    <td width="36%" bgcolor="#CCCCCC">
      <input type="file" name="ifile" id="ifile" /><cfoutput>#err1#</cfoutput></td>
    <td width="50%" bgcolor="#CCCCCC">&nbsp;</td>
<cfelseif not c1 is "">
<tr><td colspan="2">#c1#</td></tr>
    <td align="right">&nbsp;</td>
    <td><input type="submit" name="button" id="button" value="upload image" /><INPUT name="imgname" type="hidden" value="<CFOUTPUT>#url.imgid#</CFOUTPUT>" /></td>
<!--- </div>

<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1");
</script> --->

Open in new window

Question by:day6
    1 Comment
    LVL 51

    Accepted Solution

    > <cfif isDefined("ifile")>

    The problem is line 28.  Because you already defined that variable on line 4:

                  <cfparam name="form.ifile" default="">

    The variable always exists. So CF tries to run the upload code before anything is uploaded, causing the error you see. To fix it, add an extra check to make sure the variable isn't empty and it should work correctly.

               <cfif isDefined("form.ifile") AND len(trim(form.ifile))>

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
    Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now