Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Upload Problem 1

Status
Not open for further replies.

RSedlacek

Programmer
Oct 5, 1998
59
0
0
US
I have a form which people fill out to reply to a job offer. On the form they have the option of uploading a resume file. The action form uploads the file to a directory on the server and then sends the file in an email to the employer. It works great except when the applicant does not include a resume file.

Here is a snippet of code at the top of my action page.
Code:
<CFIF IsDefined("form.cvfile")>
<CFFILE ACTION="Upload"
	FILEFIELD="form.cvfile"
	DESTINATION="D:\steel-link\cvfiles\"
	accept = "text/plain, application/msword, application/pdf"
	NAMECONFLICT="MakeUnique">
	<CFELSE></cfif>

This code checks to see if the resume file (form.cvfile) exists. If it does it uploads it to the server and makes the name unique. If the file was not submitted on the form it ignores it and goes on to the rest of the page's coding.

Here is the error message I get when the form submission does not include a file...
Code:
Error Occurred While Processing Request
The form field "form.cvfile" did not contain a file.
 
The error occurred in D:\steel-link.com\2002\careers\Apply_Action.cfm: line 6

4 : 	DESTINATION="D:\steel-link\cvfiles\"
5 : 	accept = "text/plain, application/msword, application/pdf"
6 : 	NAMECONFLICT="MakeUnique">
7 : 	<CFELSE></cfif>
8 :

Any ideas???
 
The variable form.cvfile exists even if no file is selected. Check if form.cvfile is empty is a way:

Code:
<CFIF form.cvfile neq ''>

<CFUPLOAD....


</CFIF>
 
Thank you SGSE. I didn't think about that. I have made the change and all is well now. Thanks again! Tek-Tips is a life-saver!

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top