Answers.Body: <p>It propbably works to store the custom field directly with your new element model:</p>
  
  <pre><code>$assetFileModel-&gt;setContentFromPost(array(
      'captionFieldHandle' =&gt; $myCaption,
  ));
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-02T22:00:51.823Z
Answers.LastActivityDate: 2015-08-02T22:00:51.823Z
Answers.UserDisplayName: carlcs
Body: <p>I'm trying to upload an asset based on this code <a href="https://gist.github.com/sathoro/8178981" rel="nofollow">https://gist.github.com/sathoro/8178981</a>
  which works fine, but how can I add additional content fields during the upload? I would like to set the caption an additional fields like credit during the upload?</p>
  
Tags: <upload>
Title: How can I add field content to an asset in code?
ThreadText: # How can I add field content to an asset in code?
  
  (Asked by: username_0 on 2015-08-01)
  
  I'm trying to upload an asset based on this code <https://gist.github.com/sathoro/8178981>
  which works fine, but how can I add additional content fields during the upload? I would like to set the caption an additional fields like credit during the upload?
  
  **Tags:** upload
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-08-02. Score: 2 | Accepted answer
  
  It propbably works to store the custom field directly with your new element model:
  
  ```
  $assetFileModel->setContentFromPost(array(
      'captionFieldHandle' => $myCaption,
  ));
  
  ```
  
  
  ---
  
  