Search code examples
coldfusionrailolucee

Finding the source file path of a cffile upload


As noted on other cffile upload questions,

GetPageContext().formScope().getUploadResource("myFormField").getName()

is great for getting the filename on the server before actually doing the cffile (for Railo and Lucee - there's a different method for ColdFusion) but I noticed an interesting wrinkle: if the browser is IE then this returns the full source path including the filename. Firefox and Chrome on the other hand, return only the filename.

For my application I need the full path, but haven't been able to find that when the browser is FireFox or Chrome. If anyone has any ideas I would be most grateful!


Solution

  • (Expanded from the comments)

    I am not familiar with the getUploadResource() function. However, looking over this related thread, it sounds like it returns file information submitted by the client. While there are recommended guidelines, ultimately the value received on the server is whatever the browser chooses to send. It is not something that can be changed or controlled by server side code. So if Firefox and Chrome return something different than IE, you are out of luck.

    (As an aside, personally I have always found Internet Explorer to be a bit odd in this area. Traditionally browsers are restricted from certain file access operations for security reasons, unless a signed control is used. So you might expect those restrictions would prohibit a browser from submitting information about the structure of the client file system as well. In fact, most browsers do not submit path information with uploads, only a file name. Obviously, Internet Explorer chose to do things .. differently .. for whatever reason)

    For my application I need the full path

    Having said all that, why would you need the path from the client machine?