framar studios
 REAL SOLUTIONS FOR REAL BUSINESS
Nav
Home
Portfolio
Freeware
Contact
Tip
Cold Fusion and the Macintosh
Are you a Mac user? Write Cold Fusion? Consider this excellent combination: BareBones's BBEdit and Stairway's Interarchy.

[All Tips]

Download cf_ImageUpload

Frank Marion, [email protected].
http://www.framarstudios.com

Date Created: October 08, 2000 9:49:26 PM
Last Modified: August 22, 2001 3:43:09 PM

This document serves to upload an image from the client's local machine to the server, rename it to the ID of the record to which this image belongs,update the database accordingly, and display the image. It also allows for the deletion of the image file and record.

NOTES:
This requires a table in your database with at the least one field for the image file name.
The query 'GetRecordImages' assume that your Primary Key is a number. If it's not, remember to add quotes the 'where =' clause.

USAGE: All attributes other than 'DefaultImage' are required!


<cf_ImageUpload
	TheDataSource="#DataSource#"
	TheTableName="Product"
	TheKeyColumnName="ProductID"
	TheFileColumnName="Image"
	TheRecordID="#TheRecordID#"
	PathToImageDir="C:\Inetpub\wwwroot\yoursite\images"
	URLToImageDir="path/to/my/images/"
	Referrer="/MyApp/Admin/MyProductPage.cfm?Var=#Var#"
	DefaultImage="DefaultImage.gif">

ATTRIBUTES:

TheDataSource
	Required	The datasource to the database containing 
			the record to be updated. (ie. #Datasource#)

TheTableName
	Required	Name of the the table to be updated when adding,
			replacing or deleting an image. (ie.Products)

TheKeyColumnName
	Required	Name of the primary key column that the file
			of the record to be updated (ie. ProductID)

TheFileColumnName
	Required	Name of the column that contains the name of the image
			file (ie. ProductImage).

TheRecordID
	Required	ID of the record to be updated (ie. 2482)

PathToImageDir
	Required	Physical drive path to which to upload to, and from which
			to delete the image. (ie. C:\webboot\account\images\).
			Include trailing slash.

URLToImageDir
	Required	URL to the directory that contains the image (full, or relative)
			(ie. http://mydomain.com/images/) Include trailing slash.

Referrer
	Required	Full referrer, so that we can return to the original record after an upload.
			(ie:/account/app/index.cfm?Fuseaction=EditProduct?ProductID=#ProductID#)

DefaultImage
	Optional	The file name of an image to display if there is none specified
			in the database.

LICENSE:

This tag is freeware (NOT public domain). I retain all rights. You may make unlimited use of this tag for any purpose, personal or as part of a commercial work (not including re-distribution), providing that these comments are kept intact and that any changes you make are clearly documented in the comments, in your own name should you choose to re-transmit it with modification.

In other words: Use this freely, share it with your friends, use it in your commercial projects, but you may NOT re-distribute tag for a fee. It's free, give me credit of authorship and don't sell it as your own, or in a collection of some sort. If you aren't clear about this, or wish to use it in a different manner, I welcome your inquiries.

As usual, no warranties or guarantees of usefulness or even fitness for any purpose are made. This script is written as well as I know how to, and in using this, you agree to take complete responsibility for anything that may go wrong.

If you use it, please send me an email, just to that I can know my work is useful to others. Feel free to contact me with questions or suggestions. I especially welcome letters from developers who might have constructive feedback or alternate approaches. Frank Marion, [email protected]

Always check out http://www.framarstudios.com for the latest updates and more goodies.

. . .
Framar Studios. 416 531 1727 Toronto, Canada.
Real Solutions for Real Business