[eluser]Unknown[/eluser]
Hi every one,
I am having this problem in uploading image and seriously making my hairs out. I have googled and gone thorough many forums but could not solved this out.
Here is the code for uploading image
Code:
function do_upload()
{
if(is_dir('./uploads/'))
{
// echo "there is directory <br/>";
chmod('./uploads/',0777);
}
else echo "<br>there is no directory</br>";
$config['upload_path'] ='./uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
if (!$this->upload->do_upload())
{
// echo "<br/>noupload<br/>";
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
else
{
//echo "<br/>yesupload";
$userfile=$this->$_FILES['userfile']['name'];;
$data = array('upload_data' => $this->upload->data($userfile));
$image_path = $data['upload_data']['file_name'];
return $image_path;
}
}
But it shows the error The upload path does not appear to be valid. I have gone through the forums and it said to add
$this->upload->initialize($config);
but whenever i add that code nothing happens even doesn't display any errors.
Please help me out of this. Thanks in advance