Welcome Guest, Not a member yet? Register   Sign In
Undefinied variable on upload function()
#1

[eluser]Ngulo[/eluser]
hi all
i've my Home controller wich contains this function:
Code:
if(!$nome_zip or !$nome_png )
                    {
                    $this->session->set_flashdata('messaggio_upload','non hai caricato    nessun file');
                    redirect('admin/templates');
                    }
        //upload dei templates e delle immagini
        ////creo data e orario
        $la_data=date("d-m-y");
        $lo_orario=date("H:i:s");
        //scelgo tabella dove inserire dati immagini e zip
        switch($this->input->post('dir_scelta'))
              {
               case "Joomla":
               $tab_scelta='joomla_templx';
               break;
               case "Drupal":
               $tab_scelta='drupal_templx';
                break;
                case "Wordpress":
               $tab_scelta='wordpress_templx';
               break;
               }

                //la directory dove fare upload avrà nome uguale al nome delle opzione nella select del form(Joomla,Drupal,Wordpress)
                $dir=htmlentities($this->input->post('dir_scelta'));
                //filtro i nomi dei file
                $nome_zip=htmlentities(basename($_FILES['zip']['name']));
                $nome_png=htmlentities(basename($_FILES['png']['name']));
                //escape nomi
                $zip= mysql_real_escape_string($nome_zip);
                $png= mysql_real_escape_string($nome_png);
               //controllo che i file siano . zip e .png
              
                if(!strpos($nome_zip,".zip") or !strpos($nome_png,".png") )
                        {$this->session->set_flashdata('messaggio_upload','I file devono avere estensione .zip e .png');
                         redirect('admin/templates');
                         }

                
                //controllo che non esistano già i file nel db
                $query_controllo=$this->db->get_where(''.$tab_scelta,array('nome_zip_templx'=>$zip));

                if($query_controllo->result()== FALSE )
                 {
                    $query_inserisco=
                    "INSERT INTO $tab_scelta
                    (nome_zip_templx,nome_img_templx,data_templx,ora_templx )
                     VALUES('$zip','$png','$la_data','$lo_orario') ";

                    $this->db->query($query_inserisco);


                //muovo file nella cartella
                move_uploaded_file($_FILES['zip']['tmp_name'],'upload/'.$dir.'/'.$_FILES['zip']['name']);
                move_uploaded_file($_FILES['png']['tmp_name'],'upload/'.$dir.'/'.$_FILES['png']['name']);

                $this->session->set_flashdata('messaggio_upload','I files '.$nome_zip.'<br>e<br> '.$nome_png.'<br>sono stati caricato');
        redirect('admin/templates');

                 }
                 else{
                $this->session->set_flashdata('messaggio_upload', 'Il template'.$nome_zip.'è già presente nel db');
                    redirect('admin/templates');

               }
              

          
        

      
    }

the problem is that if i try to upload from the form page all works perfectly ,but if i go ,by the URL,to
Code:
mysite.com/admin/templates/upload
comes back to me an error:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: nome_zip

Filename: admin/templates.php

Line Number: 24
(wich is the first code line(
if(!$nome_zip) etc...
)

any suggestions?

thanks guys Wink




Theme © iAndrew 2016 - Forum software by © MyBB