Look how the code is to load the variables and write to the database:
This is the field: <input type="file" id="arquivo" name="jform[][]" multiple accept=".pdf"/>
Code: Select all
// SAVE FUNCTION
private function salvarArquivos($arquivos,$id) {
$db = JFactory::getDbo();
foreach ($arquivos as $arquivo) {
$arquivoData = file_get_contents($arquivo[0]['tmp_name']);
$arquivoSave = new stdClass();
$arquivoSave->location_id = $id;
$arquivoSave->name = $arquivo[0]['name'];
$arquivoSave->mime = $arquivo[0]['type'];
$arquivoSave->size = $arquivo[0]['size'];
$arquivoSave->data = $arquivoData;
$arquivoSave->created = date('Y-m-d H:i:s');
$a = $db->insertObject( '#__mymaplocations_location_arquivos', $arquivoSave, 'id' );
}
}
// SAVE ARRAY OF FILES
//$up = $data['upload'];
$data = JFactory::getApplication()->input->post->get('jform', array(), 'array');
$arquivos = JFactory::getApplication()->input->files->get('jform', null, 'files');
$id = SELF::salvarInstituicao($data);
SELF::salvarArquivos($arquivos,$id);
I use the same logic to write a checkbox type field and to be all right, see below:
Code: Select all
<input type="checkbox" id="poder" name="jform[poder][]" value="1" > <label style="font-size: 17px;">Poder Executivo (exceto empresas públicas e sociedades de economia mista)</label> <br>
<input type="checkbox" id="poder" name="jform[poder][]" value="2" > <label style="font-size: 17px;">Poder Legislativo (exceto corte de contas)</label> <br>
<input type="checkbox" id="poder" name="jform[poder][]" value="3" > <label style="font-size: 17px;">Poder Judiciário</label> <br>
<input type="checkbox" id="poder" name="jform[poder][]" value="4" > <label style="font-size: 17px;">Tribunal de Contas</label> <br>
// FUNCTION TO SAVE:
private function salvarEsfera($esferas,$id) {
$db = JFactory::getDbo();
foreach ($esferas as $esfera) {
$esferaSave = new stdClass();
$esferaSave->location_id = $id;
$esferaSave->esfera = $esfera;
$esferaSave->created = date('Y-m-d H:i:s');
$e = $db->insertObject( '#__mymaplocations_location_esfera', $esferaSave, 'id' );
}
}
$esferas = $data['esfera'];
SELF::salvarEsfera($esferas, $id)