Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

getting url path from known absolute path

Explorer ,
Oct 20, 2009 Oct 20, 2009

Is there a CF 8 function that will give me the url path for an a known OS absolute path.

For example if I have a path to a file or directory like:

C:\Inetpub\wwwroot\ccradius\public\applications\cruzcontrol\uploads\uploadpics\badday1.jpg

OR

C:\Inetpub\wwwroot\ccradius\public\applications\cruzcontrol\uploads\uploadpics\

Thanks for any help!!!

592
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 22, 2009 Oct 22, 2009

No, there's no such function.  It's a bit tricky to automate because a directory on the file system could be mapped in any number of ways on the CF server, and there's no automatic way for CF to second-guess which mapping you'd want to be using.

Basically what you need to do is to use expandPath() to expand a mapping that you want to use to resolve the file system path into a URL, and then look for a match of that in the path you are trying to convert.  If it's there, chop the file system path ac

...
Translate
LEGEND ,
Oct 22, 2009 Oct 22, 2009

No, there's no such function.  It's a bit tricky to automate because a directory on the file system could be mapped in any number of ways on the CF server, and there's no automatic way for CF to second-guess which mapping you'd want to be using.

Basically what you need to do is to use expandPath() to expand a mapping that you want to use to resolve the file system path into a URL, and then look for a match of that in the path you are trying to convert.  If it's there, chop the file system path accordingly (and flip the slashes around if needs must).

EG:

Your path:

C:\Inetpub\wwwroot\ccradius\public\applications\cruzcontrol\uploads\uploadpics\b adday1.jpg

Your root mapping:

/ => C:\Inetpub\wwwroot\ccradius\

So expandPath("/") resolves to C:\Inetpub\wwwroot\ccradius\

Now use replace() to get rid of that bit of the path from your target path:

public\applications\cruzcontrol\uploads\uploadpics\b adday1.jpg

Prepend the mapping (which is just "/" in this case):

/public\applications\cruzcontrol\uploads\uploadpics\b adday1.jpg

Use replace() to substitute the \ with /

/public/applications/cruzcontrol/uploads/uploadpics/b adday1.jpg

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 23, 2009 Oct 23, 2009
LATEST

Thanks for the help!!

Carlos

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources