使用Drupal中的服务注册个人资料图片

时间:2014-08-24 10:17:39

标签: drupal-7 drupal-services

我一直在尝试使用Service 3在用户注册期间上传用户个人资料图片,到目前为止我还没有运气。我测试了在现场通过硬编码的fid"图片"并且还试图通过字段" filemime"," filename"等等,它既没有工作也没有。 关于我需要填充哪些字段的任何想法?

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

1 个答案:

答案 0 :(得分: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;

希望这会有所帮助。

相关问题