thedlvo
thedlvo

Reputation: 1

PHP: Connect to a shared folder on the network

I am making an application in codeignite .. I need to connect to a shared folder on the network ... from there open a dbf and take the data and include them in a mysql db on ....... but to connect to the shared folder need user and pass ..... so I have no Access to the dbf this is the code:

public function update_oferta() {

   $this->load->database(); 

   $db = dbase_open('//Ventas/ventas/2013/ODEMCVC12/OFERTA.DBF', 0);

    if ($db) :

          $numero_registros = dbase_numrecords($db);

      for ($i = 1; $i <= $numero_registros; $i++) :

         $value = dbase_get_record($db, $i);  

         $codOferta = $value[49].$value[4];
         $codProducto = $value[49];
         $codDerivado = $value[87];
         $cantidadOferta = $value[52];
         $codCentro = $value[40];
         $mesOferta = substr($value[6], 4, 2); 
         $annoOferta = substr($value[6], 0, 4); 

$query = $this->db->get_where('oferta_table',array('codOferta'=>$codOferta));
        $result = $query->result();

        if (empty($result)): 

            $insert = array("codOferta" => $codOferta, 
                            "codProducto" => $codProducto,
                "codDerivado" => $codDerivado, 
                            "cantidadOferta" => $cantidadOferta,
                "codCentro" => $codCentro,
                "mesOferta" => $mesOferta,
                "annoOferta" => $annoOferta);

            $this->db->set($insert);
            $this->db->insert("oferta_table");

        endif;

      endfor;   
    endif;
  $confirm = "The update was a success"; 
return $confirm; 
}   

and this is the error:

A PHP Error was encountered

Severity: Warning

Message: dbase_open() [function.dbase-open]: unable to open database z:/2013/ODEMCVC12/OFERTA.DBF

Filename: models/vpxp_model.php

Line Number: 460

Note: I also tried mapping the folder and nothing...

Upvotes: 0

Views: 2489

Answers (1)

Stanislav
Stanislav

Reputation: 913

Looks like you need to map your network path using your network credentials.

Here is a file reading solution for Windows

Upvotes: 1

Related Questions