Showing posts with label coldfusion. Show all posts
Showing posts with label coldfusion. Show all posts

June 23, 2009

cfftp 500 Illegal PORT range rejected

Try setting the passive attribute to "yes" where your cfftp action is equal to putFile.

<cfftp action="open" server="ftp.server.com" username="username" password="password" passive="yes" connection="connectionName" >

<cfftp action="putFile" localfile="/var/www/html/#filename#" remotefile="#filename#" passive="yes" transfermode="ascii" timeout="30" connection="connectionName">

March 5, 2009

ColdFusion CFC WSDL libstdc++

I chased a problem all morning with missing libraries in Debian running ColdFusion MX. While trying to run a cfc as a web service I kept getting this error:

"coldfusion.jsp.CompilationFailedException: Errors reported by Java compiler: /opt/coldfusionmx7/runtime/bin/jikesw: error while loading shared libraries: libstdc++-libc6.1-1.so.2: cannot open shared object file: No such file or directory ."

I installed the latest version of libstdc++ and installed libc6-dev but it still didn't work until I tried Keebler's workaround. Props to him.

The end solution was to link the newer library to the old...

"ln -s /usr/lib/libstdc++-libc6.2-2.so.3 /usr/lib/libstdc++-libc6.1-1.so.2"

CFMX 7 running on Debian 4.0

October 2, 2008

Finding the hostname with CFMX 8

<cfset inetObj = CreateObject("java", "java.net.InetAddress")>

<cfset inet = inetObj.getLocalHost()>

<cfoutput>#inet#</cfoutput>

February 12, 2008

ColdFusion CFLDAP - Display images stored in Microsoft Active Directory

Not too hard once I found out how MS stores the data in the photoJpeg field of Active Directory.

<!--- imageFile.cfm --->
<cfsilent>
<cfldap action="QUERY"
name="ldap"
attributes="jpegPhoto"
start="dc=[yourdc],dc=com"
filter="sAMAccountName=[loginname]"
server="[yourserver]"
username="[username]"
password="[password]">
<cfscript>
     ldapPhoto = toString(ldap.jpegPhoto);
     ldapPhoto = binaryDecode(ldapPhoto,"base64");
</cfscript>
</cfsilent><cfcontent type="image/jpeg" variable="#ldapPhoto#">


<!--- to display the image on a page --->
<img src="imageFile.cfm" width="100" height="125" alt="">





February 16, 2007

Extending root level Application.cfc files

<cfcomponent extends="/.Application">
<cfset this.name="sub_application_name">
... methods ...
... methods ...
</cfcomponent>

That will force ColdFusion to look for the root Application.cfc file and retain your session management.

Since application behavoir starts in the local folder; if you use "Application" without the /. the code will fail saying something about the component cannot extend itself.

October 3, 2006

Filtering directories from cfdirectory in ColdFusion

The examples tell you just to loop over the query returned by cfdirectory but it is much faster to do a subquery and use it instead.

<cfdirectory action="list" directory="C:\" name="treebase" recurse="yes">

<cfquery dbtype="query" name="treebaseFiltered">
SELECT Name, Directory
FROM treebase
WHERE Type = 'Dir'
</cfquery>

December 20, 2005

CFMX 7 Verity Error: com. verity. organize. WorkSpaceException

When creating collections in ColdFusion MX 7 via the Administrator or code, you might encounter the following error:

Unable to create collection {collection name}.
An error occurred while performing an operation in the Search Engine library.
Error opening the collection: com.verity.organize.WorkSpaceException: Path not found [VdkError_PathNotFound]. (-104)
The Verity collection directory tree contains a subdirectory called ws to act as a work space during collection creation. When that directory starts to accumulate directories and files, Verity may report this WorkSpaceException.

The work space directory on a "Server Configuration" installation would be

$CFHOME\verity\Data\services\ColdFusionK2_indexserver1\ws\ whereas if Verity was installed in J2EE configuration on WebSphere on Windows for example the Verity work space directory would be {driveletter}\ColdFusionSearchService\Data\services\ColdFusionK2_indexserver1\ws\ where the Verity bits were laid down in the ColdFusionSearchService directory as a sub-installation routine.

To resolve the exception and create Verity collections again, stop the ColdFusion MX 7 Search Service, remove all the contents of the ws/ directory, then start the Search Service.

March 30, 2005

Find free disk space available on Windows with CFMX

This code will list the fixed disks and the free available space on them.

<cfobject type="COM" action="create" class="Scripting.FileSystemObject" name="Application.fso">
<cfset driveSpace=StructNew()>
<cfloop collection="#Application.fso.drives#" item="curDrive">
<!--- A DriveType of 2 indicates a fixed disk --->
<cfif curDrive.DriveType IS 2>
<cfset driveSpace["#curDrive.DriveLetter#"]=curDrive.availablespace>
<cfoutput>#curDrive.DriveLetter#: #int(trim((curDrive.availablespace/1024)/1024))# MB free</cfoutput>
<br>
</cfif>
</cfloop>

December 6, 2004

Using ColdFusion to work with SQL binary data

<CFSET FileName = "HotDogVendor.jpg">
<CFFILE ACTION="readbinary" FILE="D:\WebFiles\MyWebsite\Images\Postcards\#FileName#" VARIABLE="NEWDATA">

<cfset NewObject = toBinary(NEWDATA)>

<cfquery name="insertImage" datasource="MyDatasource" username="myusername" password="mypassword">
update images
set content = <CFQUERYPARAM VALUE="#NewObject#" CFSQLType="CF_SQL_BLOB">
where NAME = '#FileName#'
</cfquery>

...And now, how to output an image, which is stored in a SQL Server table as an image data type? Here is code which I found on another forum that appears to work (but still not the perfect solution):

<cfquery name="GetImage" datasource="MyDatasource" username="myusername" password="mypassword">
select content
from Images
where NAME = '#FileName#'
</cfquery>

<cfcontent type="image/gif; charset=8859_1">

<CFSCRIPT>
writeOutput(toString(GetImage.Content));
</cfscript>

August 17, 2004

ADSI COM code for CFMX

<cfscript>
ADSys = createObject("COM", "ADSystemInfo");
UserName = ADSys.UserName;
</cfscript>

<cfdump var="#UserName#">

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iadsadsysteminfo.asp

CFMX QuotedValueList

I found out today that if you are going to use #quotedvaluelist()# in a query that you have to use it in the query and not set it as a variable before hand.

Good:

SELECT *
FROM table
WHERE something NOT IN (#quotedvaluelist(query.column)#)

Bad:

SELECT *
FROM table
WHERE something NOT IN (#varname#)

The bad example escapes the single quotes once it is used in the query. Not fun.

August 4, 2004

Adding additional file types to verity on CFMX 6.1

Verity content-type handling is done with the style.uni file. Each collection has its own style.uni file for both file and custom collection types.

The style.uni file can be found in:

C:\FusionMX\verity\collections\collection_name\custom\style\style.uni
C:\FusionMX\verity\collections\collection_name\file\style\style.uni

You can modify the default style.uni files so that any new collections will have the new settings.

These default files are found under:
C:\FusionMX\lib\common\style\style.uni
C:\FusionMX\lib\common\style\file\style.uni
C:\FusionMX\lib\common\style\custom\style.uni

The easiest way to add new file types is to change the default setting at the bottom of the page.
default:
# /action = skip
/charset = guess