Jump to content

Recommended Posts

Hi Guys,

 

on my site i allow users to upload .doc, .pdf and image files, over time these files will build up on the server and take up a bit of space, i was thinking of adding a "clean up" button in the admin section where files/users older than a certain time are deleted from mysql and the files (unlinked) can anyone advise me on the best way to acomplish this.

 

i know i need to query the database then find all files uploaded (say after 28 days for example)

 

is that on the right track or is there another way at all?

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/54018-solved-time-limit-to-delete-from-mysql/
Share on other sites

personally... i'd only allow files to last for 1 day... so...

 

$day=date(z);
$query=mysql_query("SELECT * FROM `files` WHERE day!='$day'");
while($row=mysql_fetch_assoc($query)){
unlink($row[filepath]);
mysql_query("DELETE FROM `files` WHERE `id`='$row[id]' LIMIT 1");
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.