I want to save some player performance data to a file in the system. Currently I’m saving the file to Application.Datapath, which works both in the unity editor play sessions and Windows builds.
But when I create a WebGL build and test it on a local server, the file never gets saved. I would really appreciate if someone can tell me how to achieve this on WebGL builds as well.
I want the file saved in the server’s file system in which the WebGL build is hosted, not in client’s file system.
You can not simply “save” a file / resource on an http server. You would need to upload your file to some kind of server side script like a php script which takes the uploaded data and stores it in the file system of the server. You can not write to the clients file system anyway because that’s not allowed by the browser anyways.
Usually one would use the persistentDataPath to store data that should be kept. The browser actually provides a virtual file system that is stored on the users machine for this website only.
So if you really want to store data on the server, you have to implement an upload script on the server. Though keep in mind that servers usually do not only serve a single person. So how would you actually handle 2 or more users now? Do you have any kind of login / password system on your server?
There are way to many open questions.