0

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->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?

  • File upload fields don't have a value column. It's a 'fid' you should be assigning instead. – Alfred Armstrong Apr 11 '13 at 13:08
0

I have done it. Here is the code that I used to solved the problem.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.