[eluser]TheFuzzy0ne[/eluser]
[quote author="Rubiz’" date="1209203350"]Hello guys; my question today is more about PHP than about CI.
I need in my admin make several image uploads, if I need upload 30 images, I have to upload it same way than only 3.
I'm doing this code:
Code:
if ( $this->Edit_model->adiciona($area, $data) )
{
$lastId = $this->Edit_model->lastIdFrom ( 'subprincipal', 'id_subprincipal' );
$error = '';
if (sizeof($_FILES['lightboxThumb']))
{
for ($i=0; $i < sizeof( $_FILES['lightboxThumb'] ); $i++)
{
if ( isset($_FILES['lightboxThumb']['name'][$i]) && $_FILES['lightboxThumb']['name'][$i] != '' )
{
@$data = array(
'id_texto' => $lastId,
'thumb' => enviar ($caminho, $_FILES['lightboxThumb']['name'][$i], $_FILES['lightboxThumb']['tmp_name'][$i]) . '?',
'nome' => enviar ($caminho, $_FILES['lightboxImgs']['name'][$i], $_FILES['lightboxImgs']['tmp_name'][$i]) . '?'
);
if ( ! $this->Edit_model->adiciona('imgs_texto', $data) ) $error = '1';
}
}
}
If I put 30 images, it had to upload 30 images, but is only uploading and including in DB 5...
Anyone knows why?[/quote]
I have to be honest here.... I haven't got a clue what your code is doing, but that's most likely my fault rather than yours.
Two things pop into mind for multiple file uploads. First of all, have you made the form a multipart form? Second of all, you will need to ensure that your markup has the names of the files as an array.
Code:
<!-- File 1 -->
<input name="myfile[]" type="file" id="myfile[]" size="50" />
<!-- File 2 -->
<input name="myfile[]" type="file" id="myfile[]" size="50" />
<!-- File 3 -->
<input name="myfile[]" type="file" id="myfile[]" size="50" />
I hope this helps.