Try this lee.

<!--- Upload File Attachment, check if user has selected a file first --->
<cfif Len(Trim(form.file_rfq)) GT 0>
        <CFFILE action="UPLOAD" FILEFIELD="file_rfq"
DESTINATION="d:\webserver\mysite\www\uploads\" NAMECONFLICT="makeunique">
        <cfset uploadedfilename = CFFILE.SERVERFILE>
<cfelse>
        <cfset uploadedfilename = "">
</cfif>
<!--- End Insert --->

<!--- SQL Insert Statement - After Upload & If user selected a file to
upload --->
<CFQUERY DATASOURCE="datasourcename">
INSERT INTO rfqs(rfq_fullname,
     rfq_companyname,
     rfq_email,
     rfq_tel,
     project_name,
     project_scope,
     budget,
     timescale,
     file_rfq)
VALUES('#Trim(FORM.rfq_fullname)#',
  '#Trim(FORM.rfq_companyname)#',
  '#Trim(FORM.rfq_email)#',
  '#Trim(FORM.rfq_tel)#',
  '#Trim(FORM.project_name)#',
  '#Trim(FORM.project_scope)#',
  '#Trim(FORM.budget)#',
  '#Trim(FORM.timescale)#',
  '#Trim(uploadedfilename)#')
</CFQUERY>




-----Original Message-----
From: Lee Bailey - Element2 Limited [mailto:[EMAIL PROTECTED]]
Sent: 25 October 2001 11:39
To: CF-Talk
Subject: Problem with database insert


Hi all,

I have a form which includes a file field, however this is an optional field
for the user.  The 'insert.cfm' page checks to see if the user has selected
a file and if so gets the name of it and all the other form data and inserts
it into a database.  The problem I'm having is what code I need to use as an
'else' (if the user hasn't selected a file to upload) - everything I've
tried so far is giving me an access violation.  Code for the 'insert.cfm'
page is below....any help would really be appreciated!

Thanks,

Lee


<!--- Upload File Attachment, check if user has selected a file first --->
<cfif Len(Trim(form.file_rfq)) GT 0>
<CFFILE action="UPLOAD" FILEFIELD="file_rfq"
DESTINATION="d:\webserver\mysite\www\uploads\" NAMECONFLICT="makeunique">
</cfif>
<!--- End Insert --->
<!--- SQL Insert Statement - After Upload & If user selected a file to
upload --->
<cfif Len(Trim(form.file_rfq)) is not 0>
<CFQUERY DATASOURCE="datasourcename">
INSERT INTO rfqs(rfq_fullname,
     rfq_companyname,
     rfq_email,
     rfq_tel,
     project_name,
     project_scope,
     budget,
     timescale,
     file_rfq)
VALUES('#Trim(FORM.rfq_fullname)#',
  '#Trim(FORM.rfq_companyname)#',
  '#Trim(FORM.rfq_email)#',
  '#Trim(FORM.rfq_tel)#',
  '#Trim(FORM.project_name)#',
  '#Trim(FORM.project_scope)#',
  '#Trim(FORM.budget)#',
  '#Trim(FORM.timescale)#',
  '#Trim(CFFILE.SERVERFILE)#')

</CFQUERY>
</cfif>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to