I am wondering how company like snapchat execute their delete function. If I am about to design a feature like snapchat which the file(images, videos) will be deleted after 24 hours the video have been uploaded by the specific user is to execute sleep
in php after 24 hours.
<?php
**upload code goes here**
sleep(24);
**delete code goes here**/
?>
I know this is not the best way to do it. I searched around and found something called cron job which you can execute php code in a scheduled time. But I want to delete the specific file that upload by user after 24 hours not the specific time which when the admin execute the delete. Is there a better way to do this? Thanks