From my below code i am able to upload images with spaces and capitalizing subsequent words, but if i try to view such images into my view page then its not visible. I am getting error like The URI you submitted has disallowed characters.
I am displaying images like <img src="<?php echo base_url().'uploads/avatar/'.$avatar?>"/>
So how can i fix this error, to allow img tag to read image name with spaces and capitalizing subsequent words.
Or alternative solution, How how can i remove any spaces or capitalizing subsequent words with the image name while uploading?
I am uploading file with the 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 the file name
$this->loginmodel->update_user_basic_info($uid); //update both
}