Answers.Body: <p>You asked about SQL, but it is generally recommended to use the API rather than direct SQL. See the Attachment API - examples in the Code Docs section of API Explorer.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-27T09:09:40.403Z
Answers.LastActivityDate: 2018-03-27T09:09:40.403Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>I would do one manually with the UI, then look at tables civicrm_file, civicrm_entity_file, and the custom table to see what it creates, then base it on that. The name of the custom table depends on what field group you've put the field in, but it starts with civicrm_value_XXX.</p>
  
  <p>You might also want changelog records (civicrm_log) and would need to deal with the filename suffixes that it adds to make it harder to guess the filenames for url hacking. See Aidan's answer for an alternative using php that should handle all this for you.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-26T20:09:30.080Z
Answers.LastActivityDate: 2018-03-27T12:54:07.223Z
Answers.LastEditDate: 2018-03-27T12:54:07.223Z
Answers.UserDisplayName: Demerit
Body: <p>Is there any way through SQL commands, to import files into a custom field? E.g. photos of contacts?</p>
  
Tags: <import>
Title: Is there any way to import files into a custom field for uploaded files?
ThreadText: # Is there any way to import files into a custom field for uploaded files?
  
  (Asked by: username_0 on 2018-03-26)
  
  Is there any way through SQL commands, to import files into a custom field? E.g. photos of contacts?
  
  **Tags:** import
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-03-27. Score: 2
  
  You asked about SQL, but it is generally recommended to use the API rather than direct SQL. See the Attachment API - examples in the Code Docs section of API Explorer.
  
  
  ---
  
  ### Answer by username_2 on 2018-03-26. Score: 1
  
  I would do one manually with the UI, then look at tables civicrm\_file, civicrm\_entity\_file, and the custom table to see what it creates, then base it on that. The name of the custom table depends on what field group you've put the field in, but it starts with civicrm\_value\_XXX.
  
  You might also want changelog records (civicrm\_log) and would need to deal with the filename suffixes that it adds to make it harder to guess the filenames for url hacking. See username_1's answer for an alternative using php that should handle all this for you.
  
  
  ---
  
  