How can I change the file permissions of a .json to allow all website visitors to write to it?
I have a PHP based website in google cloud app engine that makes a basic phone book that is editable using a .json to store the data. Once you login, You can add, delete, and change entries to the phonebook. I've done the following:
- gotten all my files uploaded and working
- mapped my custom domain name
- edited the app.yaml so that PHP scripts get executed correctly
- Gotten to display the .json
- gotten to add an entry to the phonebook but cant get it to save the addition for the next login
Here is the important php code
$dbFile = 'phoneBook.json';
$json = file_get_contents($dbFile);
$depth = 4;
$phBook = json_decode($json, true, $depth);
// ...manipulation...
$fp = fopen($dbFile, 'w');
fwrite($fp, json_encode($phBook));
fclose($fp);
And i use that to manipulate the phonebook.json
Here is my app.yaml
runtime: php55
api_version: 1
threadsafe: true
runtime_config:
document_root: web
handlers:
- url: /(.+\.php)$
script: \1
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
- url: /www/checklogin.php
script: checklogin.php
The phonebook.json is in same directory as the other php files. In linux all i have to do is chmod and change the permissions to allow writes, is there anyway i can do that with what i have here? I read somewhere that you can do it if you use the compute engine VM instance instead of the app engine. is that my only choice?