I am using CodeIgnitor and oracle db

at model

function add_new_emp_test( $x, $y)
    {
        $conn=$this->db->conn_id;
      // Execute the call to the stored procedure
      $stmt = "BEGIN emp_pkg.add_account(:x1,:y1); END;";
       $lob = oci_new_descriptor($conn, OCI_D_LOB);
       $lob = oci_new_descriptor($conn, OCI_D_LOB);
      $stid = oci_parse($conn, $stmt);
      oci_bind_by_name($stid, ':x1', $x, 100);
      oci_bind_by_name($stid, ':y1', $lob, -1, OCI_B_BLOB);
      $lob->writeTemporary(base64_encode($y));

      //$lob->writeTemporary($y);


      $r = oci_execute($stid,OCI_DEFAULT);




       oci_commit($conn);

    }



        function getdata($username){


            $conn=$this->db->conn_id;
      // Execute the call to the stored procedure
      $stmt = "BEGIN emp_pkg.get_sp_account(:x, :rc); END;";

      $stid = @oci_parse($conn, $stmt);

      $refcur = oci_new_cursor($conn);

      $r = @oci_bind_by_name($stid, ':RC', $refcur, -1, OCI_B_CURSOR);

      oci_bind_by_name($stid, ':x', $username ,100);

      $r = @oci_execute($stid);

      // Now treat the ref cursor as a statement resource
      $r = @oci_execute($refcur, OCI_DEFAULT);

      $r = @oci_fetch_all($refcur, $employeerecords, null, null,
                              OCI_FETCHSTATEMENT_BY_ROW);

      return ($employeerecords);


            }

At controller

public function uploadit(){

    $config['upload_path']='application/views/x/';
    $config['allowed_types']='png|jpg';

    //$this->load->helper(array('form', 'url'));
    $this->load->library('upload',$config);
    $this->upload->initialize($config);


    echo "s";
    if ($this->upload->do_upload('f1')){
    echo "hhhahahah";
    }
    if (is_readable($config['upload_path'].$_FILES['f1']['name'])){
    echo "haaaaa";
    echo $this->upload->data('file_type'); 
    $datame=file_get_contents($config['upload_path'].$_FILES['f1']['name']);
    $this->load->model("students_mod");

$this->students_mod->add_new_emp_test("khalil111",$datame);
//  $this->students_mod->add_new_emp_test("khalil6666",$_FILES['f1']['tmp_name']);

    $this->load->model("students_mod");
    $arr['res']=$this->students_mod->getdata("khalil");






    $arra=array("datame"=>$arr['res'][0]['PIC']);
    $this->load->view("upload",$arra);
    }

    }


public function show_upload_page(){

    $this->load->view("upload");
    }



at view 


 <img src="<?php echo 'data:' . 'image/png' . ';base64,' . $datame; ?>" id="profile-picture-mini" alt=""/>




why the image doent appear 

Hi, few questions:

  • the data is correctly inserted in the database?
  • if, in view, you do var_dump($datame); what you get?
  • have you tried to remove the error control operators @ in your getdata() method? In this stage it's more important to get debug information rather than hiding.

thanks for your answer .... I forget to view the image as the following

<img src="data:image/jpeg;base64,<?php echo base64_encode($datame); ?>" width="40" height="40" />

this was the error :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.