I have a requirement to save a json file to disk.
I've got as far a the below php. However i get the following error.
fopen(/wp-content/content/uploads/artworks.js): failed to open stream: No such file or directory in
This file is in the correct location. So i assume there is a permission error. I only have ftp access to this server. Obviously wordpress has permission to write to disk. So how can i leverage this permission to save the file
$feed_url = 'http://example.com';
$remote_data = file_get_contents($feed_url);
$data = json_decode($remote_data, true);
$works = array();
foreach ($data ['rows'] as $inx => $remote_item_data) {
$works[] = $remote_item_data;
}
$fp = fopen('/wp-content/content/uploads/artworks.js', 'w+');
fwrite($fp, json_encode($works));
fclose($fp);