I'm trying to do some custom stuff with a file upload field via the form API. I call to
file_save_upload() but it thinks that the upload is empty because it's examining
$_FILES['files'] but for some reason, my file is actually in
$_FILES['CSV_file'] even when the file I uploaded is not a csv.
How might files superglobal end up with a
CSV_file array key?
So apparently the form array
$form['my_menu_csv'] = array( '#name' => 'CSV files', '#type' => 'file', '#title' => t('Choose a CSV file'), '#title_display' => 'invisible', '#size' => 22, '#theme_wrappers' => array(), '#weight' => -10, );
was causing the field to have the following HTML:
<input type="file" id="edit-my-menu-csv" name="CSV file" size="22" class="form-file">
and apparently the files array goes like
$_FILES[$name], where $name = whatever the name attribute is in the HTML element. Makes sense! What doesn't make sense is why
file_save_upload() expects to only ever encounter
$_FILES['files'] but the form API uses a custom field name. Is this a bug in the form API?