Welcome Guest, Not a member yet? Register   Sign In
How doing multiple image uploads?
#1

[eluser]Rubiz'[/eluser]
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?
#2

[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:
&lt;!-- File 1 --&gt;
&lt;input name="myfile[]" type="file" id="myfile[]" size="50" /&gt;
&lt;!-- File 2 --&gt;
&lt;input name="myfile[]" type="file" id="myfile[]" size="50" /&gt;
&lt;!-- File 3 --&gt;
&lt;input name="myfile[]" type="file" id="myfile[]" size="50" /&gt;

I hope this helps.
#3

[eluser]Rubiz'[/eluser]
Thanx for answering TheFuzzy0ne.

All thoses questions are ok, my multipart form data is ok, my inputs are arrays, and my for code is ok, is uploading my files and inserting information in DB, but only for 5 files; if I put 30, only 5 works.

I really think my for in breaking after 5 uploads.

Any idea?
#4

[eluser]gunter[/eluser]
how are your settings in the php.ini?
upload_max_filesize
post_max_size

but I believe, if you upload too much then nothing will arrive at the server... and not only the first 5 files...
so maybe the error is another thing...
#5

[eluser]Rubiz'[/eluser]
Should I use a sleep code maybe? than the for would take more time to resolve everything.
What u think?




Theme © iAndrew 2016 - Forum software by © MyBB