Question
OO/Framework, Uploading Images Issue
I am using using a form that uploads a file. If I use a self
calling form
that
reinitializes the form values from the bean cfc, my field contatining the
image no longer recognizes it as an image and the
cffile fails.
<cfif isdefined('form.staffid')>
<cfoutput> in isdefined staff </cfoutput>
<cfset staffmember = createobject('component',
'datafoo.cfc.staff').init(form)>
<!--- check for errors before saving --->
<cflock name="photolock" timeout="30">
<cffile action= "upload"
filefield='staffmember.filetoupload'
destination="#expandpath(arguments.directory)##staffmember.filename#"
nameconflict="makeunique">
</cflock
</cfif>
I get the error: The form field staffmember.filetoupload did not contain a
file.
However, if I take that form and instead of recreating the instance from the
bean.init,
just run the upload using the form variable, the image gets uploaded fine
<cfif isdefined('form.staffid')>
<cfoutput> in isdefined staff </cfoutput>
<!--- IGNORE <cfset staffmember = createobject('component',
'datafoo.cfc.staff').init(form)> --->
<!--- check for errors before saving --->
<cflock name="photolock" timeout="30">
<cffile action= "upload"
filefield='file.filetoupload' <!--- *** use form var here -
works --->
destination="#expandpath(arguments.directory)##form.filename#"
nameconflict="makeunique">
</cflock
</cfif>
Any suggestions?
In the bean init I have
<cfcomponent >
<cfproperty name="filetoupload" type="string" default="">
<cfscript>
//Initialize the CFC with the default properties values.
this.filetoupload='';
</cfscript>
<cffunction name="init" output="false" returntype="staff">
<cfargument name="stValues" required="no" type="struct">
<cfif isdefined('arguments.stValues')>
<cfset this.filetoupload = arguments.stValues.filetoupload>
<cfreturn this>
</cffunction>
</component>
Any suggestions?
--
Tami Burke
Honey House Web Designs
that
reinitializes the form values from the bean cfc, my field contatining the
image no longer recognizes it as an image and the
cffile fails.
<cfif isdefined('form.staffid')>
<cfoutput> in isdefined staff </cfoutput>
<cfset staffmember = createobject('component',
'datafoo.cfc.staff').init(form)>
<!--- check for errors before saving --->
<cflock name="photolock" timeout="30">
<cffile action= "upload"
filefield='staffmember.filetoupload'
destination="#expandpath(arguments.directory)##staffmember.filename#"
nameconflict="makeunique">
</cflock
</cfif>
I get the error: The form field staffmember.filetoupload did not contain a
file.
However, if I take that form and instead of recreating the instance from the
bean.init,
just run the upload using the form variable, the image gets uploaded fine
<cfif isdefined('form.staffid')>
<cfoutput> in isdefined staff </cfoutput>
<!--- IGNORE <cfset staffmember = createobject('component',
'datafoo.cfc.staff').init(form)> --->
<!--- check for errors before saving --->
<cflock name="photolock" timeout="30">
<cffile action= "upload"
filefield='file.filetoupload' <!--- *** use form var here -
works --->
destination="#expandpath(arguments.directory)##form.filename#"
nameconflict="makeunique">
</cflock
</cfif>
Any suggestions?
In the bean init I have
<cfcomponent >
<cfproperty name="filetoupload" type="string" default="">
<cfscript>
//Initialize the CFC with the default properties values.
this.filetoupload='';
</cfscript>
<cffunction name="init" output="false" returntype="staff">
<cfargument name="stValues" required="no" type="struct">
<cfif isdefined('arguments.stValues')>
<cfset this.filetoupload = arguments.stValues.filetoupload>
<cfreturn this>
</cffunction>
</component>
Any suggestions?
--
Tami Burke
Honey House Web Designs
