So this is kind of a strange question and you may think it is the other way around but here it comes.
I make use of a framework called Laravel. Not that it makes any difference but i thought it is worth mentioning. On this framework i have an web-application which makes it possible to rate pictures in albums.
The pictures that are being uploaded are coming in from an android application. The picture is made from a phone which converts it to base64 and sends it to the web-application. The input that it sends is being received by a controller action in my web-application.
The above does work! But now i want to trigger some kind of event in PHP when the controller action is begin used. So when a picture is being uploaded, the user that uses the web-application sees there is a new picture added to the album.
Can anyone point me in the right direction for this?
Many thanks in advance.
Well, you could be inspired by this website and drop a bar at the top of the web app notifying the user of a change.
Or create a reload button that lights up and indicates the number of changes. When the user clicks that button, the gallery could be reloaded.
Setup up a poller to check every X seconds for new images. And if there is a new image, display it.
This is how stackoverflow works for new answers. If you inspect the console tab in Firebug, you will see it poll every 30 seconds(ish).
Example (using jQuery):
setInterval(function() {
$.getJSON('/check-for-images', function(data) {
if (data instanceof Array) {
$.each(data, function(i, image) {
$('<img/>').attr('src', image).appendTo('#container');
}
}
});
}, 30000);
PHP:
$result = query('SELECT name FROM images WHERE date > :lastUpdated', $lastUpdated);
echo json_encode(fetchArray($results));