2myCharlie
2myCharlie

Reputation: 1907

How to specify a relative in CFFile?

This is the path of my json file: https://devbox.mysite.com/search/KOGroups.json But instead of using cfhttp, I like to use cfifle with read action. I don't know how to turn this path into a relative path for cffile. I've read about this ColdFusion Read File article and it looks like they use absolute path in their example. I've tried Ben Nadel's "Relative File Paths Work In A ColdFusion File System" article but the code that he provides for getting the parent directory is not working for me. All I need is to turn this path, https://devbox.mysite.com/search/, into cffile tag so I can read the .json file.

Upvotes: 1

Views: 1035

Answers (2)

Adrian J. Moreno
Adrian J. Moreno

Reputation: 14859

Use the function expandPath() for this.

expandPath('../path/to/file') returns the full server path to that file.

Upvotes: 2

2myCharlie
2myCharlie

Reputation: 1907

Looks like BKBK over in Adob coldfusion forum answered my question with the following:

<cfset koGroupsJSON = fileRead("https://devbox.mysite.com/search/KOGroups.json")>

Upvotes: 0

Related Questions