I have a function that accepts a file path. Users can pass in either an absolute or relative path to a file. If a relative path is provided, the ExpandPath function can convert it to an absolute path like so:
<cfset filepath = ExpandPath("data/test.txt") >
.. and it returns:
C:\www\example\data\test
But if user provides an absolute path like:
<cfset filepath = ExpandPath("C:\www\example\data\test") >
.. it returns:
C:\www\example\C:\www\example\data\test
How may I solve this problem?
You could test the string and see if it starts with C:\ for windows or \\ for unix, and use that as an if?
This could be your windows check: