CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • how to check upload file integrity linkage?
Pages: [1]

Author Topic: how to check upload file integrity linkage?  (Read 441 times)

mcgeehon

  • I post occasionally
  • **
  • Posts: 76
  • Karma: 0
  • CiviCRM version: 4.x
  • CMS version: 7.x
  • MySQL version: 5.x
  • PHP version: 5.2.x
how to check upload file integrity linkage?
November 17, 2012, 09:11:32 pm

I have inherited a Drupal/CiviCRM site that has a large number of custom uploaded files.  All of these files exist in /sites/default/files/civicrm/custom folder.  These files are uploaded by using a profile with custom fields.

The problem is that when a user deletes the file from their profile, the end file is never deleted, just the reference to the file.  This leaves me with hundreds of files that are no longer linked to any contact and are simply eating up space on my server.  Is there a way to validate which of these files can be deleted and which are still linked to an active profile?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: how to check upload file integrity linkage?
November 18, 2012, 08:59:44 pm
Active files are referenced in one of two places in the DB. Custom field file names can be found in civicrm_file.uri column. And contact 'images' are referenced in civicrm_contact.image_URL column. It might not be too hard to write a script which cycles through the files in your /custom directory and deletes ones that aren't referenced in the DB tables. If you do, would be great to share it as I'm not aware of one being shared to date.
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • how to check upload file integrity linkage?

This forum was archived on 2017-11-26.