tags:

views:

60

answers:

2

I looked around, and the latest reference I saw was from 2008 stating that the standard FileReference browser does not support retrieving the user's file's absolute local path unless it's an AIR app, and indeed there's nothing in the docs suggesting otherwise. The reasoning behind this is apparently some misguided security concern... I get it's not a great idea to let any Flash app know your directory structure, but if the user actually grants your app a file, I think it doesn't invalidate the security model to know just that file's absolute path.

I'm wondering if the state of things has changed at all with Flex 4 and there's a method of getting the local filename of anything. I need it because I'm making an application that when distributed runs locally in 99% of cases, so doing a full file upload just to save it somewhere else on the local machine seems silly. (Plus the standard file uploading method doesn't support SOAP, which is what I'm using for all my other services...) I can always just have the user type in their local path name, but that seems really stupid.

+1  A: 

Due to security reasons, in Flash (not AIR) you are not allowed to see the full path of a fileReference File.

Adrian Pirvulescu
A: 

It depends on what you are trying to achieve - it's not exactly clear what you're trying to do.

"doing a full file upload just to save it somewhere else on the local machine seems silly"

Since flash player 10 you can save directly to the local filesystem without going through a remote server. You just have to invoke the FileReference.download() function in response to a user guesture like a mouse click or key press (e.g. pressing a save button).

FileReference documentation: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html#download%28%29

Otherwise, no, you are not able to get the full path to a file as it can be a security risk - even if they do select the file themselves.

For example if I select a file on the desktop of a Windows machine I don't really want some random web application knowing my username:

"C:\Documents and Settings\ [user name] \Desktop\myAwesomeFile.txt"

and from that you can take a guess at the version of windows I'm running.

If you need greater interaction with a user's desktop then you should use AIR - that is it's reason for existing.

Sly_cardinal