找到你要的答案

Q:Remove Image or video file from folder after 7 days with PHP

Q:从文件夹中删除图像或视频文件后7天用PHP

I have lots of images and videos on a sub-folder of a particular user-id folder.

I have a save and update dates and one more - expiry date, which is the update date + 7 days within the database.

After 7 days this file needs to be automatically removed from the folder and deleted from the database.

What's the code in PHP for this?

我有很多图片和视频在一个子文件夹的一个特定的用户ID文件夹。

我有一个保存和更新日期和一个以上的到期日,这是更新日期+ 7天内的数据库。

7天后,该文件需要自动从文件夹中删除并从数据库中删除。

在PHP的代码是什么?

answer1: 回答1:

You should create a "cronjob" which searches your database for the files that need to be deleted, and then use the unlink function to delete the files.

你应该创建一个“任务”,搜索你的数据库,需要删除的文件,然后使用unlink函数删除文件。

php  cron