That's the same thing I do. Here's the code if anyone cares to use it. I'd
love to see if someone could improve upon it.

<!----------------//------
andy matthews
web developer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->

<!---//--------- begin code
<cfset thumbDim = 135>
<cfset largeDim = 500>

<!--- init the sleep method--->
<cfset thread = CreateObject("java", "java.lang.Thread")>

<table>
<tr class="formBG">
        <td class="formlabel required" align="right">Photo</td>
        <td>
                <cfif URL.id AND CLIENT.photo_thumb IS NOT "">
                        <img src="../images/photos/#CLIENT.photo_thumb#" 
align="right">
                </cfif>
                <input type="file" name="photo_file"><br>
                <input type="button" name="button" class="smaller" 
value="Preview Image"
onclick="previewImage(document.myForm.photo_file.value)">
                <cfif CLIENT.photo_large IS NOT "">
                        <a href="../images/photos/#CLIENT.photo_large#" 
target="_blank">View
large image</a>
                </cfif>
        </td>
</tr>
        </table>

<!--- accept the upload if it exists --->
<cfif FORM.photo_file IS NOT "">

        <cftry>
                <!--- accept the upload --->
                <cffile action="UPLOAD" filefield="photo_file"
destination="#APPLICATION.settings.photoPath#" nameconflict="overwrite"
mode="770">

                <!--- sleep for 10 --->
                <cfset thread.sleep(7000)>
                <cfset VARIABLES.photo_large = "lg_" &
LCase(ReplaceNoCase(CFFILE.serverFile," ","_","ALL"))>
                <cfset VARIABLES.photo_thumb = "th_" &
LCase(ReplaceNoCase(CFFILE.serverFile," ","_","ALL"))>

                <!--- place the file in the correct directory --->
                <cffile action="rename"
source="#APPLICATION.settings.photoPath#/#CFFILE.serverFile#"
destination="#APPLICATION.settings.photoPath#/#VARIABLES.photo_large#"
nameconflict="overwrite">

                <cfset picHeight =
APPLICATION.imgObj.getHeight("#APPLICATION.settings.photoPath#/#VARIABLES.ph
oto_large#")>
                <cfset picWidth =
APPLICATION.imgObj.getWidth("#APPLICATION.settings.photoPath#/#VARIABLES.pho
to_large#")>


                <!--- set final image dimensions --->
                <!--- if it's taller --->
                <cfif picHeight GT picWidth>

                        <!--- now see if it's bigger than the max size --->
                        <cfif picHeight GT largeDim>
                                <!--- the picture is larger than the max size 
--->
                                <cfset largeDim = 
Fix((largeDim*picWidth)/picHeight)>
                        <cfelse>
                                <!--- set the large image to be the max size 
--->
                                <cfset largeDim = picWidth>
                        </cfif>

                        <!--- set the thumbnail --->
                        <cfset thumbDim = Fix((thumbDim*picWidth)/picHeight)>

                <!--- if it's wider --->
                <cfelseif picWidth GT picHeight>

                        <!--- now see if it's bigger than the max size --->
                        <cfif picWidth GT largeDim>
                                <!--- the picture is larger than the max size 
--->
                                <cfset largeDim = largeDim>
                        <cfelse>
                                <!--- set the large image to be the max size 
--->
                                <cfset largeDim = picWidth>
                        </cfif>

                        <!--- set the thumbnail --->
                        <cfset thumbDim = thumbDim>

                </cfif>
<!---
                <cfoutput>
                picHeight: #picHeight#<br>
                picWidth: #picWidth#<br>
                largeDim: #largeDim#<br>
                thumbDim: #thumbDim#<br>
                </cfoutput>
                <cfabort>
--->

                <cfscript>
                        // source, destination, width
                        // we only resize the "large" image if it's larger than 
our specified
size of 500
                        
APPLICATION.imgObj.resize("#APPLICATION.settings.photoPath#/#VARIABLES.ph
oto_large#","#APPLICATION.settings.photoPath#/#VARIABLES.photo_large#",
#largeDim#);
                        
APPLICATION.imgObj.resize("#APPLICATION.settings.photoPath#/#VARIABLES.ph
oto_large#","#APPLICATION.settings.photoPath#/#VARIABLES.photo_thumb#",
#thumbDim#);
                </cfscript>
                <cfcatch type="any">
                        <cflocation url="#thispage#?msg=noupload" addToken="no">
                </cfcatch>
        </cftry>

</cfif>
<!---//--------- end code


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:223414
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to