3 Replies - 3077 Views - Last Post: 05 January 2007 - 08:54 AM Rate Topic: -----

#1 jspidy  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 25-February 05

upload and insert haa!

Posted 23 December 2005 - 02:50 PM

I'am haveing trouble with this bit of code
what its doin is uploading the image and inserting a link into the database,

I can upload and insert a link but its not the path of image on the server,
but the upload path of the server

Can any one see where i am going wrong.

I have tried the various cffile tags and still no joy

<cffile action = "upload"
fileField = "Image"
Destination="C:\CFusionMX7\wwwroot\example\user images\"
nameConflict = "MakeUnique"
Accept="image/*">

<cfoutput>
You uploaded #cffile.ClientFileName#.#cffile.ClientFileExt#
successfully to #cffile.ServerDirectory#.
</cfoutput>

<cfinsert datasource="userregistration" dbtype="ODBC" tablename="reguser" formfields="FirstName, LastName, UserName, Email, Password, PhoneNumber, VehicleMake, VehicleName, YearOfRegistration, EngineSize, EngineType, Tax, Test, Price, Image">

oh by the way this is the action page!!
Cheers

Is This A Good Question/Topic? 0
  • +

Replies To: upload and insert haa!

#2 wiredwizard  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 76
  • Joined: 07-May 05

Re: upload and insert haa!

Posted 22 January 2006 - 11:24 PM

You need to change over to cffile.serverfile and it will all work for yor. See sample below.
<cfif form.MYIMAGE gt "">
	<cffile action = "upload"
	fileField = "MYIMAGE"
	Destination="c:\inetpub\wwwroot\railbuffs\assets\"
	nameConflict = "MakeUnique"
	Accept="image/*">
	<cfset MYIMAGE = cffile.serverfile>
</cfif>

you might also want to drop the cfinsert and go with an insert query like so.

<cfquery name="addit" datasource="#dsn#">
  INSERT INTO table (stringfield1, numericfield1, stringfield2)
  VALUES ('string1', 1, 'string2')
</cfquery>

and just in case be sure your not using cfupdate either go with update query insteed

<cfquery name="updateit" datasource="#dsn#">
UPDATE TABLENAME
SET fieldname1 = '#form.fieldname1#',
fieldname2 = '#form.fieldname2#',
fieldname3 = '#form.fieldname3#'
WHERE somefieldname = 'something' 
</cfquery>


This post has been edited by wiredwizard: 02 February 2007 - 08:10 AM

Was This Post Helpful? 0
  • +
  • -

#3 timmaayyb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-February 06

Re: upload and insert haa!

Posted 05 January 2007 - 01:17 AM

My apologies.

This post has been edited by timmaayyb: 05 January 2007 - 12:38 PM

Was This Post Helpful? 0
  • +
  • -

#4 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 205
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: upload and insert haa!

Posted 05 January 2007 - 08:54 AM

You must use [code ][ /code] tags around your code segments, otherwise the posts become excessively long like this one.
It is posted both in the rules and in the add reply box, please use them from now on.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1