How do I How do I use the "file chooser" to load JSON file from local hard drive

0 favourites
From the Asset Store
Ludo Local Multiplayer board game can be played by 2 to 4 players
  • I am looking to use the "file chooser" to allow a user to BROWSE and SELECT

    a JSON file from their local hard drive that contains the saved game data.

    I want a user to be able to save their data to their LOCAL hard drive as a JSON file, and

    then be able to BROWSE their local hard drive to LOAD that JSON file in which is saved somewhere

    on the users hard drive.

  • Hi, what the File Chooser does is that once the user selected the wanted file, the plugin will retrieve the path of the file, under the expression ChosenPath, next you can use it with the expression ReadFile and set the content into a variable or an object, for example :

    Object > Set from Json > ReadFile(ChosenPath)

  • Hello,

    Thank you very much for the help, I really appreciate it.

    Here is a couple of screen shots for a test project CAPX I put together.

    This loads an ARRAY DATA file from the local project folder \ Files folder.

    The FIXED file is named "Data_1.txt" and it loads when I click the LOAD button

    using an AJAX Request.

    Is there a way to allow a user to BROWSE and LOAD a different ARRAY DATA file

    using the File Chooser?

    NOTE: I would also OK with using a DICTIONARY OBJECT if that might work?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ah you're making a web project, I was assuming you were using Nwjs, in that case the process is almost the same however I'll have to make some research on my own before explaining anything

  • Hello,

    Yes, my goal is to make a web browser user data page

    that allows a user to save their personal information to their LOCAL PC

    and then be able to BROWSE their PC and LOAD in different user profiles.

    So, the user fills out a web form, then SAVES that data to a file on their

    local PC.

    After that, the user can BROWSE And LOAD in different user profiles which

    are saved to their LOCAL PC.

    I hope that makes sense

  • It can be made without creating any file tho, with local storage plugin, then you can make a built in save/load interface to load or save your array/dictionary in the computer local storage, I think I already have an example ready somewhere, I'll share it once I'm home

  • Thank you tomycase..

  • Hi Tomycase, any updates on my post?

  • Hey sorry still not home, I have some travel to do before having access to my comp again, I'll be here by tomorrow

  • No worries, I really appreciate any help you can provide and I plan on posting

    my results, along with an example CAPX project for any other users who may have

    a similar question..

  • Here it is, two versions of the example :

    Simple save and load array with Local Storage

    drive.google.com/file/d/1xq6FTed8jhtOrgkKI8yHFUKpXeScQ_u9/view

    More advanced version with content of the array displayed in save slots :

    drive.google.com/file/d/1QbhycuMy43jMu5Pcse-WAi4WaYEzoNsC/view

    Everything should be explained in the files, you're free to experiment with it

  • Thank you very much, I will try this right away...

  • Hi tomycase,

    Ok, both examples work GREAT and I think I understand how it all is operating now..

    Final questions:

    1. How would I now export a localstorage slot of data to a JSON file on the users local hard drive?

    2. How would I LOAD in that JSON back in later?

  • Hi tomycase,

    I have my test project working, mostly.

    I am able to LOAD the ARRAY values from an external text JSON file.

    Filename: "Key1_data.ckd" (TEXT FILE)

    Inside the TEXT JSON file:

    {"c2array":true,"size":[5,1,1],"data":[[["B"]],[["A"]],[["A"]],[["A"]],[["B"]]]}

    I have not been able to find a way to SAVE the same ARRAY to this same TEXT JSON file

    located in my FILES folder?

    Any help would be greatly appreciated..

  • You can't modify the content inside the files folder, you need to use nwjs and a folder on the computer to do so, but anything in the files folder can't be edited at runtime

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)