This content has been marked as final. Show 10 replies
Flex application run from within a browser have security restrictions. You cannot read or write local files; you can only send and receive data from the server. So your files have to live on a server. You request them at runtime using a data service, such as HTTPService.
If you have static XML files on the server, then code the HTTPService's url parameter to point to the XML file itself. Most likely you will want to load a file based on the user or something specific. In that case you will need some server-side code, such as PHP, Flex Data Services, IIS, Java servlets, etc.
Thank you for the information. As I am currently evaluating Flex 2, I wll look into FLEX Data Services.
How can an official adobe representative be so wrong?
You can read an xml file locally, and possibly write.
And how do you do that?
You said its not possible to read and then give an example off how its possible to read from server using HTTPSERVICE,
surely you can use HTTPService to read it locally aswell.
as for writing if you use flex3 etc im sure you can use FileStream to access and modify an .xml file
You cannot use HTTPService to read and write local files. HTTPService uses the HTTP protocol to connect to a server that understands the protocol; the local file system does not. Further, the local file system is in another security sandbox. A sandbox is defined by the domain (eg, adobe.com). The domain from which the SWF is served is its home domain. Operations on data with that domain, such as HTTPService, are automatically allowed. If you try to request a file from outside that domain you have to get permission from the other domain to do so, usually in the form of a crossdomain.xml file.
The local file system cannot provide this. Plus, it would be a huge risk to allow the Flash Player to have access to the local file system. Imagine going to some website where a malicious SWF was placed, perhaps disguised as a banner add, where it then filled your drive with nonsense files, or read your files and transmitted them elsewhere.
The File classes in Flex 3 are part of the AIR package. The AIR player runs locally, thus it is in the local domain. AIR apps behave in the same way any locally installed program behaves and can read and write files. AIR apps are installed by the user and launched by the user (a user hitting a web page and getting SWFs as banner ads is not explicitly granting those SWFs permission). AIR apps can be distributed over the 'net, but not launched from the browser.
Hey Peter, i am aware of this but youre saying i cant access local files via HTTPSERVICE, when i can, the user has not stated that he is building an app for online use it could be just for local, and if so crossdomain will not apply and a simple point to the xml file using GET will do the job.
P.s: apologies for sounding very arrogant and ignorant, i had misread a bit of your reply earlier
I believe your use case is uncommon. Going forward, AIR is the way to do this as we may beef up Flash Player security a bit more.
Anti-Girl in any case : 1 or 2 you are wrong,
Case 1) as peter stated cant read client files , capish not possible, only from Server.
Case 2) if user is running app locally, then users local machine becomes also a users Server as well so that is why its possible in that case.
bottom line is still cant read client files,only from Server.
I wanted to follow up with a similar request. I am trying to get a screen capture of my application and then allow the user to save this locally. I understand this will require a round-trip to the server. I am looking for some sample code to run on the server in Java. I have done the work on the client of encoding the image into a png format and then using URLLoader to send this to the server. What I am missing is the round-trip part. When the server gets the data, how does it return it to the client and how does the client show a "save" dialog box? Will this need to be done through the browser? WIll I need to open an additional window?
Any pointers would be helpful.