3

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!

Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
Mike
  • 93
  • 7
  • 1
    I am not familiar with that method. Is it supposed to return the *client* file properties or *server* properties? It sounds like the *client* information - which is not something you have any control over from the server side. AFAIK [it is whatever the browser vendor chooses to send](http://stackoverflow.com/questions/2200100/input-type-file-for-ie-gives-full-path-need-file-name-only). – Leigh Jul 27 '16 at 21:58
  • Thanks for the reference - it's ironic that that poster wants the exact opposite of what I'm looking for! – Mike Jul 28 '16 at 13:44
  • You should include a link to you question for future reference. – James A Mohler Jul 28 '16 at 14:00

1 Answers1

2

(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?

Community
  • 1
  • 1
Leigh
  • 28,765
  • 10
  • 55
  • 103
  • So it seems that I'm doomed to use IE for the moment (and I'm marking your answer as correct). But just to explain why I need this: I have a working copy on my HD that mimics the directory structure on my development and production servers. I wrote a script that can deploy a file from my working copy to the dev or prod server, and keep an audit trail of what was uploaded. I need the full source path so that the server-side code can work out where the file should go. – Mike Jul 29 '16 at 16:03
  • Yes, IE is the only browser I have used that provides that information. BTW, I worked with a legacy system that had a homespun tool similar to that. However, instead of relying on client paths it zipped one or more source files with relative paths. Then used the archive paths when extracting and updating the sources. Not the greatest method, but ... did support deploying multiple source files with auditing. – Leigh Jul 31 '16 at 11:25
  • That's a cunning idea! – Mike Aug 02 '16 at 19:42