0
votes

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.
1
bennadel.com/blog/… looks like the [ / ] prefix is known to cause unexpected results. But the real issue is that the servlet context is somehow mapping the wrong application mapped path. I don't know how that is possible. - Barry
might this be something corrected in a more recent CF11 update? - Dan Roberts
Check to see if you have "/app" defined as a mapping in CF admin or Application.cfc. - Scott Jibben
I do have the latest Coldfusion update applied, and also 100% I do have that /app defined in application.cfc mappings. - Barry

1 Answers

1
votes

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.