joeydaly.com … tech blog & sometimes more

14Jun/100

Get filename from path

Posted by Joey

Ever want to extract the filename from a path? C:\Inetpub\wwwroot\website\app\config\template\abc.jpg
… And not want to code something stupidly insane.

Try using #GetFileFromPath(“C:\Inetpub\wwwroot\website\app\config\template\abc.jpg”)#

So…

<cfset source=” C:\Inetpub\wwwroot\website\app\config\template\abc.jpg” />
<cfset fileName = GetFileFromPath(source) />

If your variable is a URL, you can’t use GetFileFromPath (because it needs relative paths on your computer/network) – try using #ListAtLast(“http://www.example.com/example.jpg”,”/”)#

Once again…

<cfset source=” http://www.example.com/example.jpg” />
<cfset fileName = ListAtLast(source,”/”) /&gt… Continue reading

Tagged as: , No Comments
11Jun/100

Downloading an image from database

Posted by Joey

A project I’m working on involves storing asset references in a database and then later downloading the images. Why? because it takes bloody ages!

So assuming you have a table called Assets, and all the right fields. There’s two options, using cfhttp or cfimage (cf8+).


<cfset pathToActualImage = “http://www.google.com/images/hello.jpg” />
<cfset tempFileName = “test.jpg” />
<cfset tempPath = “C:\temp\” />

<cfhttp url=”#pathToActualImage#” file=”#tempFileName#” path=”#tempPath#”>
1Mar/100

Adding a watermark to original images on the fly

Posted by Joey

Found this great piece of code that will allow you to prevent users or atleast stop them a little… from downloading your images. Using the cfimage tag!

Simply use cfimage to call you’re first two images, then using ImagePaste() to mash them together, and write to the browser calling ‘#image#’.

See how you go.

<cfimage… Continue reading