【发布时间】:2010-01-03 20:13:42
【问题描述】:
由于某种原因,当我尝试要求上传文件时,我的表单会中断。这是它的代码:
$form_id = "upload_form";
$form[$form_id] = array (
'#type' => 'fieldset',
'#description' => t('This is a utility to import nodes from a Comma Separated Value file. To begin, pick a node type, and upload a CSV.'),
);
$form[$form_id]['type'] = array(
'#title' => t('Enter node type'),
'#type' => 'textfield',
// '#autocomplete_path' => '', TODO: autocomplete for node types
'#required' => TRUE,
'#description' => t('This node type should already exist. If it doesn\'t, create it first.'),
);
$form[$form_id]['upload'] = array(
'#type' => 'file',
'#title' => t('Upload CSV file'),
// '#size' => 40,
'#description' => t('This will not work for a non-CSV file.'),
// '#required' => TRUE, TODO: breaks it. why?
);
$form[$form_id]['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
$form['#attributes'] = array('enctype' => 'multipart/form-data');
在 Drupal 支持site 上,有人说不可能要求上传文件。这是真的吗?
【问题讨论】:
-
它是怎么破的?您收到错误消息了吗?
-
它不允许用户提交表单,即使选择了要上传的文件。
标签: php drupal-6 file-upload