php - Codeigniter: unable to display the uploaded image with spaces and capitalizing subsequent words -
from below code able upload images spaces , capitalizing subsequent words, if try view such images view page not visible. getting error the uri submitted has disallowed characters.
i displaying images <img src="<?php echo base_url().'uploads/avatar/'.$avatar?>"/>
how can fix error, allow img tag read image name spaces , capitalizing subsequent words.
or alternative solution, how how can remove spaces or capitalizing subsequent words image name while uploading?
i uploading file below code.
function do_upload() { $this->load->library('form_validation'); if((isset($_files['userfile']['size'])) && ($_files['userfile']['size'] > 0)) { $this->form_validation->set_error_delimiters('<li class="errorlist">', '</li>')->set_rules('userfile', 'new image', 'trim|callback_valid_upload_userfile'); } $uid=$this->session->userdata('userid'); $config['upload_path'] = './uploads/avatar/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '5000'; $this->load->library('upload', $config); if ( $this->input->post('user_id') && $this->form_validation->run() == true) { $avatar= $_files['userfile']['name']; //getting file name $this->loginmodel->update_user_basic_info($uid); //update both }
that's pretty simple, use:
$config['remove_spaces'] = true;
so have take filename $this->upload->data()
, not $_files
after upload process.
Comments
Post a Comment