admincart.cfc
<cfcomponent output="No">

<!--- The image upload --->
<CFFUNCTION name="uploadImage" access="public" returntype="struct" hint="Uploads an image to a directory on the server. Requires imagefile, fully qualified directory path, base name for image and CustomerID.">
<CFARGUMENT name="thepath" type="any" required="true"/>
<CFARGUMENT name="thefield" type="any" required="true"/>
<CFARGUMENT name="imageName" type="any" required="true"/>
<!--- SET THE REQUIRED VARS --->
<CFSET var returninfo=structnew()> <CFSET var uploadinfo=structnew()>
<cfparam name="errorReport" default="">
<!--- upload the image --->
<CFTRY>
<CFLOCK timeout="10" throwontimeout="No" name="timer" type="EXCLUSIVE">
<CFFILE action="UPLOAD"
filefield="#arguments.thefield#"
destination="#arguments.thepath#"
nameconflict="OVERWRITE" accept="image/gif,image/jpg, image/jpeg, image/pjpeg, image/bmp" />
</CFLOCK> <CFCATCH type="Any">
<CFSET errorReport="#errorReport#, Upload Error">
</CFCATCH>
</CFTRY>


<CFSET returninfo.uploadinfo=structnew()> <CFSET returninfo.uploadinfo=duplicate(cffile)>
<CFOUTPUT>
<!--- if the image is not a jpeg convert it --->
<CFTRY>
<CFLOCK timeout="10" throwontimeout="No" name="timer" type="EXCLUSIVE">
<CFX_IMAGE action="CONVERT" file="#arguments.thepath#\#cffile.serverfile#" output="#arguments.thepath#\#cffile.serverfilename#.jpg" type="JPEG" quality="85"></CFLOCK>
<CFCATCH type="Any">
<CFSET errorReport="#errorReport#, Conversion Error">
</CFCATCH>
</CFTRY>
<CFX_IMAGE action="RESIZE" file="#arguments.thepath#\#cffile.serverfile#" output="#arguments.thepath#\#arguments.imageName#_thumb.jpg" bevel="false" width="72" quality="100" thumbnail="TRUE" name="THUMBNAIL" backcolor="white"> <CFSET returninfo.thumb=THUMBNAIL_file>
<CFTRY>
<CFLOCK timeout="10" throwontimeout="No" name="timer" type="EXCLUSIVE">
</CFLOCK>
<CFCATCH type="Any">
<cfthrow message="Thumbnail Error" detail="upload error" errorcode="3">
<CFSET errorReport="#errorReport#, Thumbnail Error">
</CFCATCH>
</CFTRY>
<CFTRY>
<CFLOCK timeout="10" throwontimeout="No" name="timer" type="EXCLUSIVE">
<CFX_IMAGE action="RESIZE" file="#arguments.thepath#\#cffile.serverfile#" output="#arguments.thepath#\#arguments.imageName#_image.jpg" width="250" quality="100" name="regular"> <CFSET returninfo.regular=regular_file>
</CFLOCK>
<CFCATCH type="Any">
<cfthrow message="Regular Image Error" detail="upload error" errorcode="4">
<CFSET errorReport="#errorReport#, Regular Image Error">
</CFCATCH>
</CFTRY>
</CFOUTPUT>



<cfif errorReport is ""> <cfset returninfo.image="#arguments.imageName#_image.jpg"> <cfset returninfo.thumbnail="#arguments.imageName#_thumb.jpg">

<CFSET returninfo.imagemessage="File has been uploaded and a thumbnail has been created">
<cfelse>
<CFSET returninfo.imagemessage=errorReport>
</cfif>
<CFRETURN returninfo/>
</CFFUNCTION>


</cfcomponent>

It is called like this:

<cfif form.newImage is not "">
<cfset request.newimagename=replace(form.product_name, " ", "_", "all")>
<cfscript> newImage=application.AdminCart.uploadImage(Request.cartImages,'form.newImage', request.newimagename);
</cfscript>
</cfif>


Thanks in advance

Frederick

[EMAIL PROTECTED] wrote:

Please show code, I work with CFX Image and ran into this problem and
another problem with the Mac browser.  Let me see what I can do.

Precia

----- Original Message ----- From: "frederick valone" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 29, 2004 2:28 PM
Subject: [CFCDev] file upload from ie6 - issues





I have a cfc that uses cffile and cfx image to upload, create
thumbnails, convert to jpg and resize the image. My problem is this, the
cffile struct that is created when a file is uploaded is completely
empty when uploaded though ie6. NS 7 handles the upload correctly and
the function can continue processing the uploaded image. In IE  and NS
the  file (when I evaluate the form.image field) shows a .tmp file in
tmp directory. That is as far as IE ever gets. NS places the file with
it's original name in the correct upload dir and finishes processing.

Any ideas why this happens?

Thanks
Frederick

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at


www.mail-archive.com/[EMAIL PROTECTED]



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]



--
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with [EMAIL PROTECTED] http://shopnow.netscape.com/



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to