Answers.Body: <p>If you say the file record is correctly present in <code>civicrm_file</code> and <code>civicrm_entity_file</code> table, then only thing which is missing seems to be the entry for it in custom value table. To verify this yourself -</p>
  
  <ul>
  <li>Check the custom value table name mentioned in <code>civicrm_entity_file</code> (<code>entity_table</code> column).</li>
  <li>Open the above custom table and make sure it contains the mapping of <code>civicrm_file</code> id and <code>entity_id</code>(contact id)</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-08T07:59:51.210Z
Answers.Text: YES!
  
  That is where the problem is. THe data for all these files is missing.
  
  It seems I can import the entity_id and File_id into the custom table, putting the file_id into the custom field column. I'll try it and see.
  
  Thank YOU!!
Answers.UserDisplayName: Pancharatna dasa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-08T08:59:30.170Z
Answers.Text: Success! I created a CSV file with just the entity_id and file_id and imported it with phpmyadmin. Voila, they are all back!
Answers.UserDisplayName: Pancharatna dasa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-08T06:31:10.367Z
Answers.LastActivityDate: 2018-04-08T06:31:10.367Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>WE had some sort of corruption on our CiviCRM db and somehow lost data in different fields</p>
  
  <p>One of these was a custom field containing uploaded files</p>
  
  <p>THese files are still listed in the civicrm_file table and the file ids are also associated with the civicrm entity in civicrm_entity_file. </p>
  
  <p>BUt they do not show up in the contact profile.</p>
  
  <p>I tried adding a new file to a contact and this shows up. I can't see any difference between the record for the new file and the one for the old file.</p>
  
  <p>Any ideas how to restore these? there are 756 files, so it would be a lot of work to manually do it.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-08T19:52:20.720Z
Comments.Text: If you have logging on then you might want to look at the log_ tables to see if there is some information on who/when your data was lost
Comments.UserDisplayName: petednz - fuzion
Tags: <files>
Title: Restoring uploaded file records
ThreadText: # Restoring uploaded file records
  
  (Asked by: username_0 on 2018-04-07)
  
  WE had some sort of corruption on our CiviCRM db and somehow lost data in different fields
  
  One of these was a custom field containing uploaded files
  
  THese files are still listed in the civicrm\_file table and the file ids are also associated with the civicrm entity in civicrm\_entity\_file.
  
  BUt they do not show up in the contact profile.
  
  I tried adding a new file to a contact and this shows up. I can't see any difference between the record for the new file and the one for the old file.
  
  Any ideas how to restore these? there are 756 files, so it would be a lot of work to manually do it.
  
  **Tags:** files
  
  > **Comments:**
  > **username_1**: If you have logging on then you might want to look at the log_ tables to see if there is some information on who/when your data was lost  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-04-08. Score: 7 | Accepted answer
  
  If you say the file record is correctly present in `civicrm_file` and `civicrm_entity_file` table, then only thing which is missing seems to be the entry for it in custom value table. To verify this yourself -
  
  * Check the custom value table name mentioned in `civicrm_entity_file` (`entity_table` column).
  * Open the above custom table and make sure it contains the mapping of `civicrm_file` id and `entity_id`(contact id)
  
  > **Comments:**
  > **username_0**: YES!  That is where the problem is. THe data for all these files is missing.  It seems I can import the entity_id and File_id into the custom table, putting the file_id into the custom field column. I'll try it and see.  Thank YOU!!  
  > **username_0**: Success! I created a CSV file with just the entity_id and file_id and imported it with phpmyadmin. Voila, they are all back!  
  
  ---
  
  