Normally if you want a file path in Flex to upload a file you use FileReference() with a browse(). Last week I tried the same technique to get a file dragged from the desktop to my AIR application. After fixing a strange problem the code worked but the next problem appeared to me. With FileReference I only get the file name and I want the full path so save this to a SQLite database.
I searched quite some time to find the solution for this problem so I hope I save someone else his time with this explanation. In an AIR application you have an extra class called File. If you use this you get the full file path. Here is a little example code:
import mx.events.FileEvent;
private var openFile:File = new File()
private function openBrowseWindow():void{
openFile.addEventListener(Event.SELECT, onOpenFileComplete);
openFile.browse();
}
private function onOpenFileComplete(event:Event):void{
trace("event: "+event.target.nativePath);
}
Leave a Reply