Hi all!!!

This is my first post here so please feel free to move if it's in the wrong place :-)

Ok, i am just starting out in web development, and i have created a data entry form in DW CS3 and succesfully link it into MySQL (big deal for me!), the problems is i cannot get images to upload to the database. I am using CF locally and MySQL is also on the development machine.

So here's what i've got so far

<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">
  <cfquery datasource="affinity">   
    INSERT INTO vehicle_details (vehicle_description, contract_details, available_to, deposit, business_price, personal_price, additional_infomation, manufacturer)
VALUES (<cfif IsDefined("FORM.vehicle_description") AND #FORM.vehicle_description# NEQ "">
<cfqueryparam value="#FORM.vehicle_description#" cfsqltype="cf_sql_clob" maxlength="200">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.contract_details") AND #FORM.contract_details# NEQ "">
<cfqueryparam value="#FORM.contract_details#" cfsqltype="cf_sql_clob" maxlength="150">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.available_to") AND #FORM.available_to# NEQ "">
<cfqueryparam value="#FORM.available_to#" cfsqltype="cf_sql_clob" maxlength="45">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.deposit") AND #FORM.deposit# NEQ "">
<cfqueryparam value="#FORM.deposit#" cfsqltype="cf_sql_clob" maxlength="45">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.business_price") AND #FORM.business_price# NEQ "">
<cfqueryparam value="#FORM.business_price#" cfsqltype="cf_sql_clob" maxlength="45">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.personal_price") AND #FORM.personal_price# NEQ "">
<cfqueryparam value="#FORM.personal_price#" cfsqltype="cf_sql_clob" maxlength="45">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.additional_infomation") AND #FORM.additional_infomation# NEQ "">
<cfqueryparam value="#FORM.additional_infomation#" cfsqltype="cf_sql_clob" maxlength="45">
<cfelse>
''
</cfif>
, <cfif IsDefined("FORM.manufacturer") AND #FORM.manufacturer# NEQ "">
<cfqueryparam value="#FORM.manufacturer#" cfsqltype="cf_sql_clob" maxlength="45">
<cfelse>
''
</cfif>
)
  </cfquery>
  <cflocation url="adminwelcome.cfm">
</cfif>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>admin inside</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: small;
	color: #999999;
}
body {
	background-color: #FFFFFF;
	background-image: url(images/Background_Affinity.jpg);
	background-repeat: no-repeat;
}
#container {
	width: 900px;
	margin-top: 60px;
	margin-right: auto;
	margin-left: auto;
}
#container #form1 #button2 {
	float: right;
}
-->
</style>
</head>

<body>
<div id="container">
  <form id="form1" name="form1" method="POST" action="<cfoutput>#CurrentPage#</cfoutput>">
    <table width="582" border="0" cellpadding="2">
      <tr>
        <td width="151">Vehicle Description</td>
        <td width="230"><label>
          <input type="text" name="vehicle_description" id="vehicle_description" />
        </label></td>
        <td width="181"><label>
          <input type="button" name="button5" id="button5" value="Help!" />
        </label></td>
      </tr>
      <tr>
        <td>Contract Details</td>
        <td><label>
          <input type="text" name="contract_details" id="contract_details" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Available To</td>
        <td><label>
          <input type="text" name="available_to" id="available_to" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Deposit</td>
        <td><label>
          <input type="text" name="deposit" id="deposit" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Business Price</td>
        <td><label>
          <input type="text" name="business_price" id="business_price" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Personal Price</td>
        <td><label>
          <input type="text" name="personal_price" id="personal_price" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Additional Info</td>
        <td><label>
          <input type="text" name="additional_infomation" id="additional_infomation" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="27">Manufacturer</td>
        <td><label>
          <input type="text" name="manufacturer" id="manufacturer" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Image</td>
        <td><input name="userfile[]2" type="file" /></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Brochure</td>
        <td><label>
        <input name="userfile[]" type="file" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><input type="submit" name="Submit" id="button" value="Save Vehicle " /></td>
        <td><label>
          <input type="button" name="button2" id="button2" value="Cancel" onclick="history.back()" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><label>
          <input type="submit" name="button6" id="button6" value="Delete Vehicle" />
        </label></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <input type="hidden" name="MM_InsertRecord" value="form1" />
  </form>
</div>
</body>
</html>

So i'm thinking i must be missing a small command somewhere, but as i say i am a novice so if anyone out there can help me i'd be very grateful!!

Hope to hear from someone soon :-)

Thanks in advance!!

Couple of things here:

Use CFFILE to upload the files to the server.

(http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_f_02.html#4003197)

You also need to change the form's encoding type to multipart. I have updated your code below:

<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">

	<!--- Set the destination folder.  Use ExpandPath to properly map the folder. --->
	<cfset filePath = ExpandPath("/uploads") />

	<!--- Upload the image file.  Notice that the fileField value is not enclosed in #s.  This is the correct syntax --->
	<cffile action="upload" filefield="form.imageFile" nameconflict="makeunique" destination="#filePath#" result="imageUpload" />
	
	<!--- Upload the brochure file. --->
	<cffile action="upload" filefield="form.brochureFile" nameconflict="makeunique" destination="#filePath#" result="brochureUpload" />

	<cfquery datasource="affinity">   
		INSERT INTO 
				vehicle_details 
				(vehicle_description, contract_details, available_to, deposit, business_price, personal_price, additional_infomation, manufacturer, imageFile, brochureFile)
		VALUES (
				<cfif IsDefined("FORM.vehicle_description") AND FORM.vehicle_description NEQ "">
					<cfqueryparam value="#FORM.vehicle_description#" cfsqltype="cf_sql_clob" maxlength="200">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.contract_details") AND FORM.contract_details NEQ "">
					<cfqueryparam value="#FORM.contract_details#" cfsqltype="cf_sql_clob" maxlength="150">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.available_to") AND FORM.available_to NEQ "">
					<cfqueryparam value="#FORM.available_to#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.deposit") AND FORM.deposit NEQ "">
					<cfqueryparam value="#FORM.deposit#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.business_price") AND FORM.business_price NEQ "">
					<cfqueryparam value="#FORM.business_price#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.personal_price") AND FORM.personal_price NEQ "">
					<cfqueryparam value="#FORM.personal_price#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.additional_infomation") AND FORM.additional_infomation NEQ "">
					<cfqueryparam value="#FORM.additional_infomation#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.manufacturer") AND FORM.manufacturer NEQ "">
					<cfqueryparam value="#FORM.manufacturer#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("imageUpload") AND Len(Trim(imageUpload)) NEQ 0>
					<cfqueryparam value="#imageUpload.ServerFile#" cfsqltype="cf_sql_varchar">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("brochureUpload") AND Len(Trim(brochureUpload)) NEQ 0>
					<cfqueryparam value="#brochureUpload.ServerFile#" cfsqltype="cf_sql_varchar">
				<cfelse>
					''
				</cfif>
			)
	</cfquery>
  
  <cflocation url="adminwelcome.cfm">
  
</cfif>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>admin inside</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: small;
	color: #999999;
}
body {
	background-color: #FFFFFF;
	background-image: url(images/Background_Affinity.jpg);
	background-repeat: no-repeat;
}
#container {
	width: 900px;
	margin-top: 60px;
	margin-right: auto;
	margin-left: auto;
}
#container #form1 #button2 {
	float: right;
}
-->
</style>
</head>

<body>
<div id="container">

  <!--- Set the form encoding type to multipart. --->
  <form id="form1" name="form1" method="POST" enctype="multipart/form-data" action="<cfoutput>#CurrentPage#</cfoutput>">
    <table width="582" border="0" cellpadding="2">
      <tr>
        <td width="151">Vehicle Description</td>
        <td width="230"><label>
          <input type="text" name="vehicle_description" id="vehicle_description" />
        </label></td>
        <td width="181"><label>
          <input type="button" name="button5" id="button5" value="Help!" />
        </label></td>
      </tr>
      <tr>
        <td>Contract Details</td>
        <td><label>
          <input type="text" name="contract_details" id="contract_details" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Available To</td>
        <td><label>
          <input type="text" name="available_to" id="available_to" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Deposit</td>
        <td><label>
          <input type="text" name="deposit" id="deposit" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Business Price</td>
        <td><label>
          <input type="text" name="business_price" id="business_price" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Personal Price</td>
        <td><label>
          <input type="text" name="personal_price" id="personal_price" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Additional Info</td>
        <td><label>
          <input type="text" name="additional_infomation" id="additional_infomation" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="27">Manufacturer</td>
        <td><label>
          <input type="text" name="manufacturer" id="manufacturer" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Image</td>
        <td><input name="imageFile" type="file" /></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Brochure</td>
        <td><label>
        <input name="brochureFile" type="file" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><input type="submit" name="Submit" id="button" value="Save Vehicle " /></td>
        <td><label>
          <input type="button" name="button2" id="button2" value="Cancel" onclick="history.back()" />
        </label></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><label>
          <input type="submit" name="button6" id="button6" value="Delete Vehicle" />
        </label></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <input type="hidden" name="MM_InsertRecord" value="form1" />
  </form>
</div>
</body>
</html>

I hope this helps. Let me know if you need anything.

That's great!! Thanks, really appreciate the time you've taken for me.

Unfortunatly i'm getting this error now when i try to use it:

The web site you are accessing has experienced an unexpected error.
Please contact the website administrator. 

The following information is meant for the website developer for debugging purposes.  

Error Occurred While Processing Request  
Complex object types cannot be converted to simple values.  
The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values. 
The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a cfif tag. 
 
  
Resources: 
Enable Robust Exception Information to provide greater detail about the source of errors. In the Administrator, click Debugging & Logging > Debug Output Settings, and select the Robust Exception Information option. 
Check the ColdFusion documentation to verify that you are using the correct syntax. 
Search the Knowledge Base to find a solution to your problem. 

 
Browser   Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.2.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; InfoPath.1) 
Remote Address   127.0.0.1 
Referrer   [url]http://localhost:8500/affinity_new_site_testing/updatedcode.cfm[/url] 
Date/Time   07-Jul-08 07:17 PM

Don't suppose you know what's up with it do you? :-)

Go into the ColdFusion Administrator and turn on Robust Debugging. Check the line number and let me know where the error is occurring. I didn't get a chance to actually test this, so I probably missed something.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.