Link to home
Start Free TrialLog in
Avatar of Shwapy
Shwapy

asked on

How do I get my form to submit if file upload field is left blank?

Hi folks, this is probably an easy one Im fairly new to CF.  I have a simple form for the user to fill out.  I added two file upload fields to the form that will store the file in a directory on the server and store the absolute path in the database.  Everything works fine when files are uploaded but when the user skips uploading a file the page will not go through. (This will not be a mandatory field) Im getting the error VARIABLE FULLFILEPATH IS UNDEFINED.

I added <cfif (form.agenda) NEQ ""> for the code to move on if there is no file to be uploaded but its getting hung up on <cfset FullFilePath="http://########item/#CFFILE.ServerFilename#.#CFFILE.ServerFileExt#">

I hope Im explaining this ok.  Any help would be appreciated.  

<cfif form.operation IS "Submit">
 
<cfset destination=GetDirectoryFromPath(CGI.PATH_TRANSLATED) & "docs\">
<cfif (form.agenda) NEQ "">
<cffile
	action="upload"
	filefield="agenda"
	destination=#destination#"
	nameconflict='makeunique">
 
<cfset FullFilePath="http://########docs/#CFFILE.ServerFilename#.#CFFILE.ServerFileExt#">
</cfif>
 
 
<cfset destination=GetDirectoryFromPath(CGI.PATH_TRANSLATED) & "item\">
<cfif (form.item) NEQ "">
<cffile
	action="upload"
	filefield="item"
	destination=#destination#"
	nameconflict='makeunique">
 
<cfset FullFilePath1="http://########item/#CFFILE.ServerFilename#.#CFFILE.ServerFileExt#">
</cfif>
 
	<cfquery name="submit_kc" datasource="#DS#">
	insert into
#kch#(office,classification,title,day,month,year,location,participants,purpose,agenda,item)
	values('#form.office#',
		'#form.classification#',
		'#trim(form.title)#',
		'#form.day#',
		'#form.month#',
		'#form.year#',
		'#trim(form.location)#',
		'#trim(form.participants)#',
		'#trim(form.purpose)#',
		'#FullFilePath#',
		'#FullFilePath1#'
)
</cfquery>
</cfif>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of erikTsomik
erikTsomik
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shwapy
Shwapy

ASKER

Thanks for your help!!