My code works fine with my local server, but when put on my production server (shared hosting) the text files won't write. If I manually navigate to the location of the text files and refresh, the changes are made. I've tried changing the file permissions (777 and 755) on the text files and the php files and still nothing. I'm at a complete loss.
The code:
PHP
$json = file_get_contents($search);
$searchf = fopen('../data/id.json', 'w');
fwrite($searchf,$json);
fclose($searchf);
Also works in localhost written like this:
$searchf = "../data/id.json";
file_put_contents($searchf,$json);
Ajax/jQuery
$.ajax({
url: 'includes/ig-id.php',
type: "post",
data: {
'user': user
},
success: function () {
//Get IG id
$.getJSON("data/id.json", function (response) {
var data = response;
data = data.data[0].id;
//Send response to function
instaFeed(data);
});
}
});
function instaFeed(data) {
var feed = data;
$feed.html("");
$.ajax({
url: 'includes/ig-user.php',
type: "post",
data: {
'feed': feed
},
success: function () {
//Get IG feed
$feed.html("");
$.getJSON("data/feed.json", function (response) {
$feed.html("");
var data = response;
var length = 10;
$spin.css("display", "none"); //CSS spinner
for (var i = 0; i < length; i++) {
var $img = $("<img>", {
src: data.data[i].images.thumbnail.url
});
//Send response to page
$("#feed").append($img);
}
}).fail(function () {
$spin.css("display", "none");
$feed.html("This artist's Instagram is private.");
});
}
});
}
Again all this works fine in MAMP and has worked on my school's production server so I think its a problem with my personal server's configuration?