I'm creating a company directory using our existing Active Directory information. I'm able to pull all the data I need, but I wanted to use Active Directory for the photo as well.
I found this snippet of code on this blog: http://plus10.blogspot.com/2008/02/coldfusion-cfldap-display-images-stored.html
<!--- 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="">
I plugged in all my server data and I get the error
The image "....imagefile.cfm" cannot be displayed because it contains errors
Why isn't the image displaying? and how can I correct the code?
I did a <cfdump>
on the query and it just shows as "jpegPhoto" not binary data.
I can't post the actual page because it is on an internal network only.
Note, the poster answered her own question. The cfcontent
and img
tags should be replaced with a cfimage
tag using the source attribute and action="writeToBrowser"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With