How to create, open, save and close a file or directory in javascript?
Is there a cross-pla开发者_如何学编程tform way to do these actions? Or only open files, the user download the files. I want to make a mmo side-scrolling game, and it needs to save maps, sprites and musics.
It's not possible to access the local filesystem at the client's side. If your data is text (image ->
text through base64 data uri's), the DOM Storage may be interesting for you. The files must be base64-encoded at the server's side, though.
References:
- https://developer.mozilla.org/en/data_URIs
- https://developer.mozilla.org/en/DOM/Storage
JavaScript has no I\O capabilities by itself.
If you want to reduce the traffic use the model in Travian:
- the user can save all of the resource files needed to his PC, device etc;
- the user submits to the server the path, where the resource files are saved;
- the game generates custom css with localpath (the path to the files on his machine).
This will reduce the traffic enormously.
精彩评论