Image Upload Using ColdFusion | monkeyflash

ballscauliflowerSoftware and s/w Development

Jun 30, 2012 (5 years and 1 month ago)

334 views

Image Upload Using ColdFusion | monkeyflash.com http://www.monkeyflash.com/coldfusion/image-upload/
1 of 2 8/15/2008 9:43 AM
Skip to Content
monkeyflash.com
Tutorials on Flash, CSS, HTML and more!
Image Upload Using ColdFusion | monkeyflash.com http://www.monkeyflash.com/coldfusion/image-upload/
2 of 2 8/15/2008 9:43 AM
5. To pass this information back to the parent form and close the popup window, we use a JavaScript function called LoadImage(). The JavaScript code goes between the head tags of the imagepopup.cfm file, and reads like
this:
<
script language
=
"JavaScript"
>
<!--
// function to populate the form and to close this window.

function
LoadImage
(
ImageNameJS
,
ImageExtJS
)
{

var
FormName
=
"FeatureForm"
;

var
FieldName1
=
"ImageName"
;

var
FieldName2
=
"ImageExt"
;

var
FieldName3
=
"UpdateImage"
;

var
MyImageName
=
ImageNameJS
;

var
MyImageExt
=
ImageExtJS
;

var
MyProcess
=
"Update"
;


eval
(
"self.opener.document."
+
FormName
+
"."
+
FieldName1
+
".value=MyImageName"
)
;

eval
(
"self.opener.document."
+
FormName
+
"."
+
FieldName2
+
".value=MyImageExt"
)
;

eval
(
"self.opener.document."
+
FormName
+
"."
+
FieldName3
+
".value=MyProcess"
)
;
window.
close
()
;
}
//-->
</
script
>
6. Finally, back on the parent form that started it all, we use a simple <cfif> to check to see if an image has been uploaded, (that is, if the formfield FeatureImage is not blank,) and display the new image. Otherwise, the
placeholder is used.
<cfoutput>
<img

name=
"ImageSrc"

<cfif
Form.FeatureImage N
EQ

""
>
src="images/
#Form.FeatureImage#
"

&
lt
;cfelse&
gt
;
src="images/placeholder.gif"

</cfif>
border="0" />
</cfoutput>
We now finish the rest of this form as usual, and submit the information to the database using the Submit button on this page.
Of course, the logic on this set of pages is customized for our particular needs. You can rearrange the logic as you see fit, but remember that the actual upload process is handled by the <cffile> tag itself, and happens the
instant the tag is executed by the server.
Rate this tutorial