Accessing the local file system with Flex

Source: Internet
Author: User
You can not access the local file system with Flex due to the Flash Security Sandbox with the exception of uploading files which give you tightly regulated access. I told my client this, but they really wanted to use flex and told me to find a way to do it. I considered having clients upload a file and then download it back to flex, but some users are on slow connections the client did not think that it was a viable alternative. they wanted cross platform/browser support so a Java Applet seemed the way to go. thanks to the flex Ajax Bridge on Adobe Labs I knew JavaScript cocould connect to flex and I had previusly worked with Java applets and JavaScript, so I knew I had a means for the two to communicate. the application is straight forward. I created a flex application with a text box and a button. I created a signed Java applet that lets you browse and read files. I used the Ajax bridge to setup an event listener form the flex button to a JavaScript function that called the file browse in the Java applet. once the applet reads the file it calla JavaScript function that then sends the data back to flex through the bridge. of course the dedevil is in the details or in the varous security issues within all three technologies in this case.

See it in action at: http://www.kellyjo.com/code/flexjava/FlexJava.html
* It only loads text files, binary files will cause an error. I know it works in IE, but Firefox has issues with it and I haven't tested it with other browsers.

Java code: http://www.kellyjo.com/code/flexjava/localfile.java
Flex code: http://www.kellyjo.com/code/flexjava/FlexJava.mxml
Flex Ajax Bridge: http://labs.adobe.com/wiki/index.php/Flex-Ajax_Bridge

In the end I convinced the client that flex really wasn't the technology to use since the application also required us to digitally sign, save, and load clients on the client machine. I don't know that I 'd recommend using this technique in a production site, but it's conceptually interesting.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.