如何以drupal模块方式将文件上传到文件夹位置... 我正在创建一个模块(示例),我想创建一个n上传文件,以便它应该存储在一个特定的位置(文件夹)..使用cck pls帮我...我编码像这样
$form['pem_file_upload'] ['certificates'] = array (
'#type' => 'file',
'#value' => 'upload',
'#title' => t('upload your certificate file'),
'#description' => t('Upload the certificate file which is helpfull in sending push messages to ios device'),
'#default_value' => variable_get('certificates', ''),
);
variable_set('certificates', $form_state['values'] ['certificates']);
$form['pem_file_upload'] ['certificates'] = array (
'#type' => 'file',
'#value' => 'upload',
'#title' => t('upload your certificate file'),
'#description' => t('Upload the certificate file which is helpfull in sending push messages to ios device'),
'#default_value' => variable_get('certificates', ''),
);
variable_set('certificates', $form_state['values']['certificates']);
答案 0 :(得分:3)
用于保存文件本身,这是您需要的功能
$file = file_save_upload('pem_file_upload', array(), 'public://yourfolder' . variable_get('document_path', ''), FILE_EXISTS_RENAME);
if ($file) {
//Set the status of the uploaded file.
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
}
public://是一种流格式,指向sites / all / default / files 有关更多信息,请参阅drupal 7 file api