Grab parameter from URL

Asked

Viewed 523 times

0

I need a code that when I click on the image, this image will open in a new tab. So far I have managed to make that when I click on my image it opens another tab with the image path in the URL. How do I take this path that is in the URL and make the image appear on my page, and my code is in Codeigniter and MVC. This image is saved in my database.

The code I’m using to open the image is:

  function abreFoto(){
                window.open('<?= base_url('ControllerL/verFoto' + $l->foto_caminho ,'_blank'); ?>');
            }

my controller:

public function verFoto($id) {
            $data['id'] = $id;
            $data['foto'] = $this->ML->getFoto($id);

        $this->load->view('ViewFoto', $data);
    }

my Model:

public function getFoto($id) {
        $this->db->select('fots.foto_id, fots.foto_caminho, laus.Laudo_id');
        $this->db->from('fots');
        $this->db->where('laus.Laudo_id', $id);
        $q = $this->db->get();
        return $q->result();
    }

1 answer

2

To get URL parameters in Codeigniter, you use:

$this->input->get('nome_do_parametro'); 

You can take the parameter by the URI segment as well:

$this->uri->segment(3); // Onde segmento 1 = controller; 2 = Método; 3+ = Parâmetros  

I hope it helped

Browser other questions tagged

You are not signed in. Login or sign up in order to post.