由于某些原因,当我尝试进行文件上传时,表单会中断。下面是它的代码:Drupal:需要上传文件吗?
$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,有人说,这是不可能使所需的文件上传。这是真的?
它是如何突破?你是否收到错误信息? – Evert 2010-01-04 09:18:34
即使选择了上传文件,也不会让用户提交表单。 – 2010-01-04 18:28:03