与大量用户的文件关联
如果这是一个愚蠢的问题,我很抱歉我有以下代码
function trc_upload_file() {
$form['trc_upload_form'] = array(
'#type' => 'managed_file',
'#title' => 'Upload File',
'#descripion' => 'Uplaod files',
);
$form['#submit'][] = 'trc_upload_file_submit';
return $form;
}
function trc_upload_file_submit($form, &$form_state) {
$file = file_load($form_state['values']['trc_upload_form']);
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
/*file_usage_add($file, 'trc_upload_page', 'user', $account->uid);*/
drupal_set_message(t('You Uploaded Successfully!'));
}
,工作正常 如何使用 file_usage_add() 函数,我可以将它用于 user_roles 而不是个人用户吗?
I am sorry if this is a dumb question I have the following code
function trc_upload_file() {
$form['trc_upload_form'] = array(
'#type' => 'managed_file',
'#title' => 'Upload File',
'#descripion' => 'Uplaod files',
);
$form['#submit'][] = 'trc_upload_file_submit';
return $form;
}
function trc_upload_file_submit($form, &$form_state) {
$file = file_load($form_state['values']['trc_upload_form']);
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
/*file_usage_add($file, 'trc_upload_page', 'user', $account->uid);*/
drupal_set_message(t('You Uploaded Successfully!'));
}
this is working fine
how to use file_usage_add() function, can i use it for user_roles instead individual users.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Clive 所确认的,这应该有效:
file_usage_add($file, 'trc_upload_page', 'role', $roleID);
让我们知道您的进展情况,
As Clive has confirmed, this should work:
file_usage_add($file, 'trc_upload_page', 'role', $roleID);
Let us know how you get on,