I am trying to build a web based file manager where I can view, create, edit, and delete folders and files. I need a data structure for storing the information about the files folders and subfolders.
I was trying JSON, but the problem is that there can be any number of subfolders inside subfolders which will come dynamically.
I wrote by hand a JSON test file, which the link is given below
{
"home": {
"file1": {
"type": "file",
"name": "test",
"ext": "pdf",
"date": "12/03/2015"
},
"file2": {
"type": "file",
"name": "test",
"ext": "doc",
"date": "31/01/2010"
},
"folder1": {
"type": "folder",
"name": "folder1",
"date": "11/01/2010",
"in": {
"file": {
"type": "file",
"name": "test3",
"ext": "pdf",
"date": "23/01/2017"
},
"folder2": {
"type": "folder",
"name": "folder2",
"date": "22/03/2011",
"in": {
"file4": {
"type": "file",
"name": "test3",
"ext": "pdf",
"date": "23/01/2017"
}
}
},
"folder4": {
"type": "folder",
"name": "folder4",
"date": "11/09/2009",
"in": {
"file5": {
"type": "file:",
"name": "file5",
"date": "11/09/2011"
}
}
}
}
},
"folder7": {
"type": "folder",
"name": "folder7",
"date": "23/08/2015",
"in": {
"file7": {
"type": "file",
"name": "file7",
"date": "11/01/2016"
}
}
}
}
}
There will be a dynamic generation of folders and subfolders which needed to be updated in the JSON file.
How can I access all the data from the JSON file after encoding into a variable in PHP or JavaScript, and update the file with new data as well?
Thank you