<!---

*********************************************************************************************************
A way to upload,rename,store,retreive,drill-down and display images or .swf files
with the appropriate code to support the files type.
*********************************************************************************************************

This page is a an assembly of code snippets from 3 .cfm templates that
upload image/swf files,rename,store and provide hyper-link drill down
pages that display a single image/swf file.

1st page-<UploaderACT.cfm)- The page that provides code to upload file

2nd page-<NextN5.cfm)-This page loops through the pictures in a reltated
category. Uses query record set cfloop to output
contents in hyperlink form. (ex. Gallery.cfm?PicID=12)
Code logic is provided to determine if file is .swf or
.jpg/.gif file

3rd page-<Gallery.cfm)-This page is the final part of the data drill down.
This page displays the picture contained in the
image primary key URL variable that was created
when the hyperlink.
--->

--------------------------------------------------------------------------------------------------------

<!---UploaderACT.cfm--->

<!---Set variable to store path to photo--->
<CFSET photoDir = ExpandPath(newPath)>

<!---Upload photo--->
<cffile
           action=
"upload"
           destination=
"#photoDir#"
           filefield=
"FORM.PicFile"
           nameconflict=
"makeunique"
           mode=
"777">

<!---To give the image a truly unique name of create a variable to catch the date/time on the
system clock,now this ensures the name is unique here is what the filename would
look like.... 11291204170438.swf --->

<CFSET img1= UserID& DateFormat(Now(),"DDMMYY") & TimeFormat(Now(),"HHmmss")>

<!---now append the date/time stamp created in the image1 variable with a new variable
named img that uses the name that was created in the <cffile> upload--->

<CFSET img=ListAppend(img1,FILE.ServerFileExt,".")>

<!---Now rename the image and store it in the appropriate folder--->
<CFFILE ACTION="RENAME"
            SOURCE=
"#photoDir#/#CFFILE.ServerFile#"
            destination=
"#photoDir#/#img#">

<!---Call function to insert photo into DB and return us the PK of the image just inserted--->
<CFSET NewKey=PicAdd(FORM.PicName,FORM.PicCaption,FORM.DateAdded,FORM.CatID,img,FILE.ServerFileExt)>

<!---Now call function to insert pic into UserPics tbl. That table matches pics with users--->
<CFSET inserted=KeyInsert(NewKey,UserID)>

---------------------------------------------------------------------------------------------------

<!---NextN5.cfm--->

<TR>

    <!---Output queryrecordset containing all the images in URL.#x# category--->
    <cfloop query="PicOutPut" startrow="#URL.StartRow#" endrow="#EndRow#">
    <TD align="center">
        <!---We gotta check to see if the file is a image or flash movie set a variable and use The FindNoCase() function to search the file name for the letter combo of .swf If the file does not contain .swf the variable will be set to zero --->
        <cfset IsFlash=FindNoCase(".swf","#PicOutPut.Alias#")>

        <!---If it not a flash file display it as a regular image--->        
        <CFOUTPUT>
        <cfif IsFlash eq 0>
            <img src="#CatDesc.Description#/#PicOutPut.Alias#" height="100" width="100">
            <BR>
            <B>
TITLE</B>:&nbsp;
            <a href="Gallery.cfm?PicID=#PicOutPut.PicID#">#PicOutPut.PicName#</a>

            <!---If its not a movie don't show a thumbnail of the picture include a default image that informs the user the file is a movie --->
       <CFELSE>
            <img src="images/Im_A_movie.gif">
            <BR>
            <B>
TITLE</B>:&nbsp;
            <a href="Gallery.cfm?PicID=#PicOutPut.PicID#">#PicOutPut.PicName#</a>
       </cfif>
       </CFOUTPUT>
    </TD>
    <CFIF CurrentRow MOD 3 EQ 0></TR><TR><TD align="center" colspan="3"><img src="images/graybar.gif"></TD></TR><TR></CFIF>
    </cfloop>


<!---Gallery.cfm--->

<!---On this page we run a query on the PicID passed in the URL variable to obtain
specific info about the image and and using a variable containing that query
result we outout the file. Using a little code logic and we determine
if its a .swf file and if so include the appropriate code to dsplay the file
--->

    <cfif IsFlash eq 0>
        <CFOUTPUT>
<img src="#LCase(getDesc.Description)#/#getInfo.Alias#"></CFOUTPUT>
    <cfelse>


        <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                     codebase=
"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
                     WIDTH=
"800" HEIGHT="600" id="<CFOUTPUT>#getInfo.Alias#</CFOUTPUT>">

                <PARAM NAME=movie VALUE="<CFOUTPUT>#LCase(getDesc.Description)#/#getInfo.Alias#</CFOUTPUT>">

                <PARAM NAME=quality VALUE=high>

                <PARAM NAME=bgcolor VALUE=#FFFFFF>

                <EMBED src="<CFOUTPUT>#LCase(getDesc.Description)#/#getInfo.Alias#</CFOUTPUT>" quality=high bgcolor=#FFFFFF WIDTH="800" HEIGHT="600"
NAME=
"<CFOUTPUT>#getInfo.Alias#</CFOUTPUT>" ALIGN="" TYPE="application/x-shockwave-flash"
PLUGINSPAGE=
"http://www.macromedia.com/go/getflashplayer">
                </EMBED>

    </OBJECT>

    </cfif>

-------------------------------------------------------------------------------------------
There you have it!!! A way to upload,rename,store,retreive,drill-down and display images or .swf files
with the appropriate code to support the files type. This is basic code and can be modified for ease of use
and pesonalization. If you would like to take a look at the function code email me at:
sitemanager@blueflydatadesign.com

About This Tutorial
Author: Michael "Newkirk" MacDonald
Skill Level: Intermediate 
 
 
 
Platforms Tested: CFMX
Total Views: 33,609
Submission Date: December 30, 2004
Last Update Date: June 05, 2009
All Tutorials By This Autor: 5
Discuss This Tutorial
  • Unfortunatelly it does not work for me :( Error Diagnostic Information An error occurred while evaluating the expression: photoDir = ExpandPath(newPath) Error near line 4, column 7. ----------------------------------------------------------- Error resolving parameter NEWPATH

Advertisement

Sponsored By...
Powered By...