How do I convert a URLpath to SysFilePath if I have the file's URL?

I'm in a writing mood, so decided to tackle this question:

One of your pages talks about how to get a/the filepath from a URL path; so if I know the URL where a file is, can I obtain the (absolute) path, on the server, where this file is? I will gladly supply more details, I just now would like to know if this is doable, in general. thanx!!

This is a hard question to address. First, I don't intimately remember all my 560 blog posts, and the user did not let me know which one he was referring to. Second, I am not aware which technology the user is referring to. Does he want an answer for Flex? Or AIR? Or ColdFusion?

I decided to tackle answers in all three technologies. Assuming you have a URL, how do you get the system path to the file?

In CF, I believe expandPath should give you the absolute file path. Just strip out the domain name of the URL before calling it. In Flex I do not believe you can access the file path of the server, nor the client. The security sandbox prevents such access.

In AIR, a URL to a local file is also the absolute path; but you wouldn't have access to the absolute path on the server.

So, in summary, for ColdFusion use the expandPath function. In Flex or AIR, you need a convoluted work around, such as a server side service or a desktop server piece like Merapi.

You can always ask me your question here, or stop by a Flextras Friday Lunch session and ask me in person.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
All Content Copyright 2005, 2006, 2007, 2008, 2009 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version 5.9.2.002.