由於某些原因,當我嘗試進行文件上傳時,表單會中斷。下面是它的代碼: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