Discussion in 'PHP/MySQL Development' started by TommyB, Apr 18, 2006.

  1. TommyB New Member

    Afternoon all,

    I'm going to be trying to create a community site soon with a forum etc and want people to be able to have avatars. Now the one thing i'm worried about is that if people change an avatar that is uploaded to the server and then change to a new one my web space could be filled up quite quickly. Does anyone know of a way I could use php or similar to check if an image is no longer used and if so remove it? I know i could get people to link to external avatars but not everyone has the know how.

  2. BurningSnowman Moderator

    You would have to check the forum database for all the images that are in use, then compare arrays of names and delete files which aren't but still exist. This would have to be done regularly via a cron job.

    A more sensible approach would be to modify the forum's own file upload script to delete a user's old avatar file when a new one is uploaded/selected, if it doesn't already. If multiple users can select one avatar image, then obviously check nobody else is using it either before deletion.

Share This Page