How to assign value from one file field to another programmatically? I have a webform which have a file field. In the user profile I have also created a file field.

I am using the webform for user registration So I am assigning the values from the webform to the user profile fields programmtically on webform submit.

But I am unable assing the uploaded file in the webform to the user profile file field.

I am using the following code for assigning the file.

  $user-&gt;field_user_file['files']['und'][0]['value'] = $form_state['values']['submitted']['field_webform_file'];


but it did not work.

Any Idea what should I do for this?
I have done it. Here is the code that I used to solved the problem.

  $file = file_load($fid);
  $user-&gt;field_user_file = array(
    'und' =&gt; array(
      '0' =&gt; array(
        'fid' =&gt; $file-&gt;fid,
        'filename' =&gt; $file-&gt;filename,
        'filemime' =&gt; $file-&gt;filemime,
        'uri' =&gt; $file-&gt;uri,
        'status' =&gt; 1,
        'display' =&gt; 1
      )
    )
  );