Search code examples
coldfusioncoldfusion-11

Strange ColdFusion path issue (ExpandPath resultant)


Hoping someone on here knows ColdFusion, and further, may know what is going on.

<cfscript>
    sz_test1=ExpandPath("/app/folder/afternoon.jpg");
    sz_test2=ExpandPath("app/folder/afternoon.jpg");

    WriteOutput(sz_test1&"<br />");
    WriteOutput(sz_test2&"<br />");
    abort;
</cfscript>

Simple code, simply outputting ExpandPath() results.

Situation:

Website running ColdFusion 11 prints out an image to a page based on time of day. Simple page, if it's in afternoon, you get afternoon.jpg, otherwise morning.jpg. ExpandPath is required since we actually output the page contents to a pdf (cfdocument + cfimage), which isn't important for purpose of this question. But letting you know so no one suggests not using ExpandPath as a resolution..

Problem

Somehow on this page, just 5 minutes ago, the resultant for variable sz_test1 would come back with the ColdFusion path. Not the web root path.

C:\Coldfusion11\CFIDE\app\folder\afternoon.jpg

whereas sz_test2 would give:

C:\inetpub\wwwroot\app\folder\afternoon.jpg

So naturally the file doesn't exist in the first case. But now, suddenly, ColdFusion is no longer doing that. Both tests return the exact same result. This has been consistently happening (consistently inconsistent results) for a few weeks.

Question:

Anyone know what would cause the ExpandPath() function to:

  1. Return inconsistent results when prefixed with a slash
  2. Return different results suddenly without any change to the code (or environment) whatsoever.

Solution

  • You might want to try using thisPath=getDirectoryFromPath (getCurrentTemplatePath); thisFile="#thisPath#/folder/afternoon.jpg";

    It's a little bulky but might get rid of the inconsistent behavior.