Is it possible to upload a complete directory stru

2019-08-23 13:35发布

问题:

Is it possible to upload a complete folder with subdirectories and files (in the subdirectories) in Flex?

I am using a Flex / BlazeDS / Spring application. The question is not how to transfer the data to the server. The question is: if it is possible to get access to the files and subfolders (recursive) with Flex?

回答1:

If you're working with AIR, then yes. Look a the File class. It is a reference to either a file or directory. You can tell if it is a directory using the isDirectory attribute. You can use getDirectoryListing to get a list of all files and subdirectories in a directory.

As far as I know, you'll then have to upload things one by one to the server, though.

If you are using Flex in a web based app, I do not believe what you're trying to accomplish is possible.



回答2:

No, not if you are talking about a Flex app running in a web browser. In an AIR application it is probably possible, but not in Flash Player in a browser.

The security sandbox doesn't give that kind of file system access, files are only available when selected by a user, via some user action like clicking a button. And then you only get a reference to the file, so it can be read or uploaded, there is no mechanism to for example get the local path to the file as a string or such, and no way to check for subfolders (unless it's an app for the AIR runtime).