Possible to import file to / export file from inside HTML5 game?

[Creator 3.8.2]

Hello there,

I am making a game where users create their own platformer levels and I was wondering if it is possible to export files in-browser and read values from files on a player’s computer. This sort of functionality would be amazing, as it would allow level-sharing between creators.

How might I create an “export level” button which, when pressed, exports a .txt file to the user’s downloads folder? Also, is there a way to read data from the same file from any directory on the user’s computer into the game, to be saved as a cookie in-browser? I only need to read the data from the file, not save it as an asset in-game.

Lastly, is there a proper way to turn any form of data (specifically a string) into a text file like the one described above?

I know these are a lot of questions, but any help would be extremely helpful to me! I’ve spent multiple hours looking but haven’t found anything useful yet. If someone can give me a working answer to all 3 questions, they will receive a mention in the credits of my game.

Also, if a mod is reading this, is it possible to have my username changed? I am reachable by DM :slight_smile:

Bump - This question is pivotal to my game’s success, if anyone who is reading needs clarification on my question (shouldn’t be necessary imo) and might possibly be able to give an answer, please reach out to me!

On the web, you cannot really read files from the player’s computer. The browser is a self-contained sandbox, it does not have the system context, only the browser context.

While Cocos does not provide a file system for such cases, if you are working with only a web platform in mind, you can try to use Web APIs to access the browser file system → De File System Access API: vereenvoudigt de toegang tot lokale bestanden  |  Capabilities  |  Chrome for Developers.
How to Create and Save text file in JavaScript?

Nonetheless, you still will need to figure out how to read such .txt files in Cocos space. For that, I believe the easier way would be to have a server where the users could upload the .json / .txt files and then your game could react to such new uploads using an HTTP or Web Sockets connection

For “cookies” based data, you can use the localStorage API and work with text values → User Data Storage | Cocos Creator

Since you are not considering App Store releases, I would say that Hot Update tunnel is also a possibility → Assets Hot Update Tutorial | Cocos Creator

Thanks, I’ll take a look :slight_smile: