简体   繁体   中英

Read a local text file using flash or javascript?

Is there any hook to react to a user drag and dropping a text file onto a browser? If the user drops a text file onto the browser with my page loaded, I'd like to be able to open the contents of the text file using javascript. I don't think this is possible, but just checking.

Is something like this possible in flash?

As an alternate, the user could specify a file path for me, then I could open the text file and read it. Seems like this is a security risk and probably won't be allowed, but just checking. It looks like this is possible with flash 10?

Thanks

您无法使用Javascript读取本地文本文件,因为它违反了浏览器安全模型。

i think the last option is possible. maybe you can ask for a file path from javascript. you have some filepickers for this(google it)

then send te file-path to Flash by useing ExternalInterface or flashvars

and then handle the file-path as string in flash

see:

http://www.republicofcode.com/tutorials/flash/loading_external_text_bc/

如果将文本文件(或图像,文档等)拖放到打开的浏览器中,浏览器将打开该文件进行读取-就像document.write命令一样,它会擦除​​现有文档。

Flash Player browser plugin is definitely not capable of handling drag-and-dropping of files (unlike AIR runtime, that can handle it -- but it's a matter of desktop apps). The only way to accomplish that in a browser I know is using something like Google Gears . Confluence uses gears for uploading multiple images at once by dropping them into browser window, for instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM