php - Codeigniter - loading images from browser -


i've made upload form using ci. photos uploaded in c:\xampp\htdocs\ci_new\uploads*.jpg

i want these images accessible web, can add path database, when try load them via localhost/ci_new/uploads/*.jpg gives me error - image files arent there (so im wrong folder stuff guess).

could please tell me need put images, folder public visitors , can fill path url in database.

this upload code if needed:

function do_upload(){     $config['upload_path'] = './uploads';     $config['allowed_types'] = 'gif|jpg|png';      $config['max_size']='5000';     $config['max_width'] = '1024';     $config['max_height']= '768';      $this->load->library('upload',$config);      if(!$this->upload->do_upload()) {         $error = array('error'=>$this->upload->display_erros());         $this->load->view('upload_form', $error);     } else {         $data=array('upload_data'=>$this->upload->data());         //$this->db->insert('images', $data);         $this->load->view('upload_success', $data);         print_r($data);     } } 

thank you.

make sure have converted image file name in order convert special characters not allowed in url.

try:

$filename = explode('.', $filename); $tmp_filename = str_replace(" ", "_", $filename[0]);                  /* replaces space '-' */ $tmp_filename = preg_replace('/[^a-za-z0-9\-]/', '_', $tmp_filename);                  /* removes special chars */ $tmp_filename = preg_replace('/_+/', '_', $tmp_filename);                  /* replaces multiple '_' single */  $filename = $tmp_filename.             '.'             .$filename[sizeof($filename)-1];            /*concatenating extension again.*/ 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -