Unable to get absolute path of template - coldfusion

I am not able to get absolute path of current template. Here are the functions that I tried:
#ExpandPath( "./" )#<br />
#GetCurrentTemplatePath()#<br />
#GetBaseTemplatePath()#<br />
#ExpandPath( CGI.script_name )#<br />
and here is the output (All relative paths):
/var/www/html/
/var/www/html/testPaths.cfm
/var/www/html/testPaths.cfm
/var/www/html/testPaths.cfm
Is there some setting in CFAdmin that I am missing?

The path you're getting back is the absolute path, but on a linux server, not a windows server. Linux paths don't have a drive letter.

When I looked at the debugging info on our development server, the following cgi variables have what you appear to want.
CF_TEMPLATE_PATH=D:\DW\dwtest\Dan\testcf.cfm
PATH_TRANSLATED=D:\DW\dwtest\Dan\testcf.cfm

Related

Set relative path folder in Svelte Build

Set relative path folder in Svelte build
When I build my svelte app with the command npm run build, it's export the links like this:
<script type="module" crossorigin src="/assets/index-54c7d896.js"></script>
<link rel="stylesheet" href="/assets/index-d3d038e5.css">
More accurately it call to the root localhost/assets...
// src="/assets/index-54c7d896.js"
// href="/assets/index-d3d038e5.css"
And I get this:
Error from the navigator
From here:
where I want use the svelte app
And easy solution is using a relative path to:
// from "/assets/..." to "./assets/..."
src="./assets/index-54c7d896.js"
href="./assets/index-d3d038e5.css"
But the thing is I can't do that inside javascript and css files.
These still use an absolute path.
So this is what happens:
when a css file call other files using absolute path
I mean I could dig into a compiled file but it's not efficient
I tried change manually the paths on each file but it's a lot of work each time than I have to compile.
I'm using a hosting with php so I tried using .htaccess but it's hard too.
I am expecting this to be configurable from svelte.
I really love ❤️ this framework, thanks in advance for your help.

directoryExists evaluates to true and lists contents, but cannot find directory

I have some code that uploads a video to the server, but first checks that the upload directory exists and creates it if not.
<cfif not directoryExists(tempUploadVideoDIR)>
<cfdirectory action="create" directory="#tempUploadVideoDIR#">
</cfif>
I wasn't finding the uploaded file, or the directory for that matter, in my file structure, so I ran a "list" function on the directory:
<cfdirectory name="getFiles" directory="#tempUploadVideoDIR#" action="list">
<cfdump var="#getFiles#">
and it lists the contents of the directory complete with my uploaded video.
I have checked the paths and they are all correct. I am definitely working on the correct server.
Where the heck is the directory?
localhost, CF9.02, IIS7.5
Consider using very important function in that matter- expandPath. Propably your path is relative and this function will make it absolute and working.

Creating a symbolic link with ColdFusion

This is a real toughy... Google doesn't seem to have any clue... So I leave it to my lovely friends here...
I'm trying to create a symbolic link of a file with ColdFusion... and I'm starting to get pretty peeved with not being able to resolve this as yet...
here's my code so far...
<cfset argString = '/c mklink #UserScreenPath##AdvertSubDirectory#\backgrounds\#AdvertBackgroundFilename# #Path#files\clients\#UserID#\assets\backgrounds\#AdvertBackgroundFilename#' >
<cfexecute name="cmd.exe" arguments="#argString#" outputFile="" timeout="0" />
Given that The variables are all legit and resolve correctly and that the directories resolving to the source and destination directories are also legit... What the hell am I missing?
I've tried using CFCATCH and that's come up with nothing! The environment ColdFusion is running in is Windows XP, thus the cmd.exe call...
Windows XP doesn't include a way to make symbolic links. You can, however, use the Junction tool.

Move a directory in ColdFusion and Railo

In Adobe ColdFusion (ACF), I've always used cffile action="rename" to move both files and directories. Not unreasonably, Railo doesn't think cffile applies to directories, so you need to use cfdirectory rename, and that works fine. However, that doesn't appear to work in ACF.
For example:
<cfdirectory action="RENAME" directory="C:/tmp/aaa1/aaa2/" newDirectory="C:/tmp/aaa2">
...works in Railo, but in ACF throws this:
The specified directory attribute C:/tmp/aaa1/aaa2/ cannot be renamed to newdirectory C:\tmp\aaa1\C:\tmp\aaa2.
So it seems you'd have to use cffile to move directories on ACF, and cfdirectory on Railo.
Is that really the state of the art? Is there some way to get cfdirectory to move a directory on ACF?
It shouldn't matter, but it works if you use backslashes.
I'd class this as a bug in CF (I'm testing with CF9.0.1) as for all other file operations I am aware of, either slash works fine on CF.
We developed an application in CF10 that used forward slashes for the file path in cfdirectory action="rename".
<cfdirectory action="rename" directory="//fileserver/folder10/test/TEST74036JJ_CW" newdirectory="//fileserver/folder10/TEST74036JJ_CW">
This code appeared to run fine in CF10.
When we moved the code to a CF8 server, we received the same error with the newdirectory path being appended on to the end of the original directory.
The specified directory attribute //fileserver/folder10/test/TEST74036JJ_CW cannot be renamed to newdirectory \\fileserver\folder10\test\fileserver\folder10\TEST74036JJ_CW
So, it does appear that CF10 can now handle forward slashes for cfdirectory action="rename".
I get a solution only with a change. On the attribute newDirectory do not write the path, only write the new folder name and ready. Try it. This was the option for me. I use coldfucion 9.0.1

cfinclude: template not found exception + symbolic link + CF 9.0.1

I had following directory-structure:
/user1/
/user1/bla.cfm
/index.cfm
and created a directory called users:
/users/
/user1/
/user1/bla.cfm
/index.cfm
I set up a symbolic link (under linux with ln -s) from /user1/ to /users/user1/ and tried to <cfinclude> the bla.cfm which worked good. From index.cfm:
<CFINCLUDE template="users/user1/bla.cfm" />
After some testing I removed the symbolic link (/users/user1/) and moved the real directory /user1/ to /users/user1/. Suddenly the bla.cfm did not let me include and threw a template not found exception.
After setting up the symbolic link from /users/user1/ to /user1/ the <cfinclude> worked again. I cannot reproduce this on our development server!? Any hints how to fix this?
Btw all user-directories (user2, user3, etc.) have a bla.cfm inside - and just 2 are having the problem described above. It seems that those users were active and the bla.cfm was included via the symlink. Are those symlinks and their targets cached somewhere?
EDIT:
I tried already clearing the template-cache in CFAdmin.
Further testing:
from index.cfm:
expandpath("/users/user1/bla.cfm") -> correct path
fileexists(expandpath("/users/user1/bla.cfm")) -> saying "YES"
but:
fileexists(expandpath("users/user1/bla.cfm")) -> saying "NO"
Maybe it's some issue with mappings? In the last include you're using absolute path, where in the first one you're using relative path.
Here are some links about mappings:
http://www.coldfusionmuse.com/index.cfm?mode=entry&entry=8E676EBA-A0EF-5BB2-1461BEA3C00CC076
http://forums.adobe.com/thread/442033
Coldfusion mapping error
You don't specify how you setup a 'symbolic link' - do you mean you created a mapping in CF Administrator? If so, check the neo-runtime.xml file in your /cfusion/lib/ folder and see if has been correctly updated.
Restarting coldfusion server instance fixed the problem.