Welcome Guest, Not a member yet? Register   Sign In
Upload in multi directory
#1

[eluser]federcla[/eluser]
hello,

some days I am following a project using CodeIgniter but I'm new with this tool and are not prepared

I have a problem with a file uploading, it should load in multiple directories but the process only writes in the first directory, do not understand where the error could you help me?

Code:
foreach ($this->input->post('mycheck') as $csig => $id_ent)
            {
                $config['upload_path'] = './css/'.$csig;
                $config['allowed_types'] = 'css';
                //echo $config['upload_path']."<br>";
                //$config['max_size'] = '100';
                $this->load->library('upload', $config);
                if($this->upload->do_upload('file')==false){
                    $ctr=0;    
                    echo array('error' => $this->upload->display_errors());
                    $this->load->library('Myview');
                    $this->myview->show_site($this,'webservices/modifiche_errore',$data);
                }else{
                    $d =$this->upload->data();
                    //$config['upload_path'] = './css/';
                    echo $config['upload_path']."<br>";
                    $this->load->library('Myview');
                    $this->myview->show_site($this,'webservices/modifiche_ok',$data);
                }
            }

thanks
#2

[eluser]Krzemo[/eluser]
Aparently there is only one mycheck element in submited form...
#3

[eluser]federcla[/eluser]
I'm doing the test with 2 elements in the array, the first cycle enters into the correct directory and inserts the file does not change directory in the second round, remains in the previous and inserts the file again.

Code:
$config['upload_path'] = './css/'.$csig;
#4

[eluser]Krzemo[/eluser]
maybe somehow it doesnt get the directory change...
try this:
Code:
$config['allowed_types'] = 'css';
$this->load->library('upload', $config);
foreach ($this->input->post('mycheck') as $csig => $id_ent)
            {
                $config['upload_path'] = './css/'.$csig;
                $this->upload->initialize($config);
                if($this->upload->do_upload('file')==false){
                    $ctr=0;    
                    echo array('error' => $this->upload->display_errors());
                    $this->load->library('Myview');
                    $this->myview->show_site($this,'webservices/modifiche_errore',$data);
                }else{
                    $d =$this->upload->data();
                    //$config['upload_path'] = './css/';
                    echo $config['upload_path']."<br>";
                    $this->load->library('Myview');
                    $this->myview->show_site($this,'webservices/modifiche_ok',$data);
                }
            }
#5

[eluser]federcla[/eluser]
Works! Thanks for the help, I did not know how to solve this problem

Ciao, Claudio from Rome Smile




Theme © iAndrew 2016 - Forum software by © MyBB