2

在使用 Service 3 进行用户注册期间,我一直在尝试上传用户个人资料图片,但到目前为止我还没有运气。我测试了在“图片”字段中传递硬编码的fid,还尝试传递“filemime”、“文件名”等字段,但它也不起作用。关于我需要填充哪些字段的任何想法?

我想它一定与这篇文章有关Using Drupal Services and DIOS SDK for setting user picture in iOS app 但它既没有也没有回答。

4

1 回答 1

1

我使用以下代码 -

//Picture is first uploaded from ios using file service and fid is passed in $data object
$file_contents_object = file_load($data->picture_fid);
$file_contents_array['fid'] = $file_contents_object->fid;
$file_contents_array['uid'] = $file_contents_object->uid;
$file_contents_array['filename'] = $file_contents_object->filename;
$file_contents_array['uri'] = $file_contents_object->uri;
$file_contents_array['filemime'] = $file_contents_object->filemime;
$file_contents_array['filesize'] = $file_contents_object->filesize;
$file_contents_array['status'] = $file_contents_object->status;
$file_contents_array['timestamp'] = $file_contents_object->timestamp;
$file_contents_array['rdf_mapping'] = $file_contents_object->rdf_mapping;
//use your cck field here
$user_obj->field_user_profile_picture['und'][0] = $file_contents_array;

希望这会有所帮助。

于 2014-08-25T12:04:47.970 回答