CFfile -- value is not set to the queried data

Posted by user494901 on Stack Overflow See other posts from Stack Overflow or by user494901
Published on 2011-01-06T22:03:45Z Indexed on 2011/01/06 22:53 UTC
Read the original article Hit count: 227

Filed under:
|
|
|
|

I have this add user form, it also doubles as a edit user form by querying the data and setting the value="#query.xvalue#". If the user exists (eg, you're editing a user, it loads in the users data from the database. When doing this on the <cffile field it does not load in the data, then when the insert goes to insert data it overrights the database values with a blank string (If a user does not input a new file). How do I avoid this?

Code:

Form:

<br/>Digital Copy<br/>
<!--- If null, set a default if not, set the default to database default --->
<cfif len(Trim(certificationsList.cprAdultImage)) EQ 0>
 <cfinput type="file" required="no" name="cprAdultImage" value="" >
 <cfelse>
    File Exists: <cfoutput><a href="#certificationsList.cprAdultImage#">View File</a></cfoutput>
    <cfinput type="file" required="no" name="cprAdultImage"  value="#certificationsList.cprAdultImage#">
</cfif>        

Form Processor:

<!--- Has a file been specificed? ---> 
<cfif not len(Trim(form.cprAdultImage)) EQ 0>
    <cffile action="upload" filefield="cprAdultImage" destination="#destination#" nameConflict="makeUnique">
    <cfinvokeargument name="cprAdultImage" value="#pathOfFile##cffile.serverFile#">
<cfelse>
    <cfinvokeargument name="cprAdultImage" value="">
</cfif>

CFC

ARGS:

<cfargument name="cprAdultExp" required="NO">
<cfargument name="cprAdultCompany" type="string" required="no">
<cfargument name="cprAdultImage" type="string" required="no">
<cfargument name="cprAdultOnFile" type="boolean" required="no">   

Query:

UPDATE mod_StudentCertifications
SET 
cprAdultExp='#DateFormat(ARGUMENTS.cprAdultExp, "mm/dd/yyyy")#',
cprAdultCompany='#Trim(ARGUMENTS.cprAdultCompany)#',
cprAdultImage='#Trim(ARGUMENTS.cprAdultImage)#',
cprAdultOnFile='#Trim(ARGUMENTS.cprAdultOnFile)#'

INSERT INTO 
mod_StudentCertifications(
cprAdultExp,
cprAdultcompany,
cprAdultImage,
cprAdultOnFile

© Stack Overflow or respective owner

Related posts about coldfusion

Related posts about files