> I've got a form that includes an upload field, and the form also inserts
> into a database. Everything works fine as long as there is a file being
[quoted text clipped - 3 lines]
>
> The relevant code is shown below. Any ideas?
Just for future reference, it would have been helpful if you'd mentioned
which LINE the error occurred on (and minimise the code you post, as most
of it is irrelevant to the problem).
But I suspect it is a conflict between this line:
<cffile action="upload" filefield="file"
destination="D:\inetpub\Afolder\screens\" nameconflict="makeunique">
And this line:
<cfset TheImage = File.ServerFile>
Two things:
1) "file" - as a reference to the structure returned by CFFILE ops - is
deprecated. Use cffile. eg: cffile.ServerFile.
2) I'm guessing CF is confusing the form-field called "file" and the
file-ops struct called "file", and thinking yuo're referencing the form
field (which will be a string).

Signature
Adam
PS: please note that posts made via the news feed (which I'm assuming
you're doing, as your message ain't on the web UI) are not making it to the
web UI @ present, so if you have more problems, it's probably best to post
them via the web UI, as your audience will be bigger.
Bill - 28 Dec 2004 21:04 GMT
The error is happening on this line:
<cfset TheImage = File.ServerFile>
> > I've got a form that includes an upload field, and the form also inserts
> > into a database. Everything works fine as long as there is a file being
[quoted text clipped - 31 lines]
> web UI @ present, so if you have more problems, it's probably best to post
> them via the web UI, as your audience will be bigger.
Bill - 28 Dec 2004 21:10 GMT
I changed file.serverfile to cffile.serverfile, and changed the form element
name from "file" to TheFile, and now I'm getting a different error:
Element SERVERFILE is undefined in CFFILE.
The error occurred in D:\inetpub\Afolder\trouble\tcreateticket.cfm: line 18
16 : <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
17 : <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
"form1">
18 : <cfset TheImage = CFFile.ServerFile>
19 : <cfquery datasource="ticketdsn">
20 : INSERT INTO TCreateTicket (StationNumber, ProbDescription, Frequency,
StatusofProb,
> > I've got a form that includes an upload field, and the form also inserts
> > into a database. Everything works fine as long as there is a file being
[quoted text clipped - 31 lines]
> web UI @ present, so if you have more problems, it's probably best to post
> them via the web UI, as your audience will be bigger.
Bill - 28 Dec 2004 21:31 GMT
Nevermind. I moved line 18 elsewhere and it works fine now.
> I changed file.serverfile to cffile.serverfile, and changed the form element
> name from "file" to TheFile, and now I'm getting a different error:
[quoted text clipped - 49 lines]
> > web UI @ present, so if you have more problems, it's probably best to post
> > them via the web UI, as your audience will be bigger.
Adam Cameron - 28 Dec 2004 21:51 GMT
<cfif IsDefined("FORM.file") AND #FORM.file# NEQ "">
<cffile action="upload" filefield="file"
destination="D:\inetpub\Afolder\screens\" nameconflict="makeunique">
</cfif>
So the <cffile> op is only executed depending on form.file (form.thefile
now)...
> 16 : <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
> 17 : <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
> "form1">
> 18 : <cfset TheImage = CFFile.ServerFile>
But this line of code will run even if the file op didn't take place (and
I'm guessing it didn't).
Stick a <cfdump var="#form#"> @ the top of the template, and <cfdump
var="#cffile#"> immediately after the <cffile> tag. And <cfabort> before
you get to the erroring line.
I suspect your form is passing something other than what you think.

Signature
Adam
Bill - 28 Dec 2004 22:17 GMT
Thanks Adam. Your fresh perspective helped me figure it out.
Bill
> <cfif IsDefined("FORM.file") AND #FORM.file# NEQ "">
> <cffile action="upload" filefield="file"
[quoted text clipped - 21 lines]
>
> Adam