Welcome Guest, Not a member yet? Register   Sign In
codeigniter file uploaded path
#1

[eluser]Chilukuri Bhaskar[/eluser]
Hi

I am facing problem with uploaded file path code follows
here

$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$this->load->library('upload',$config);

files are not moving that place please help me

thanks
#2

[eluser]Sanjay Sarvaiya[/eluser]
Hi,

Be sure that an uploads directory is writable.

Try this
Code:
$config[‘upload_path’] = ‘./uploads/’;
instead
Code:
$config[‘upload_path’] = ‘uploads/’;
#3

[eluser]Chilukuri Bhaskar[/eluser]
files are not moving to folder
#4

[eluser]Chilukuri Bhaskar[/eluser]
Hi

my problem is i am saving image name into database file folder. File is not moving to folder
how to move uploaded files to folder?
#5

[eluser]Sanjay Sarvaiya[/eluser]
please past your code
#6

[eluser]Chilukuri Bhaskar[/eluser]
Thanks for reply controller code here


$this->load->library('form_validation');

$this->form_validation->set_rules('name', '', 'trim|required');
$this->form_validation->set_rules('location', '', 'trim|required');
$this->form_validation->set_rules('dob','', 'trim|required|');
$this->form_validation->set_rules('bio', '', 'trim|required');

$config['upload_path'] = 'assets/uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$this->load->library('upload',$config);

if($this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('addBiography', $error);


}else
if($this->form_validation->run() == FALSE)
{
$this->load->view('addBiography');

}else{

$data = array('upload_data' => $this->upload->data());

//print_r($data);exit;

$this->load->model('artist_model');
$uploadedData = $this->upload->data();
$FileName = $uploadedData['file_name'];
$this->artist_model->addBiography($FileName);
$this->load->view('addBiography',$data);

}
#7

[eluser]Sanjay Sarvaiya[/eluser]
please always past your code in code tags. so it can easily read by any one.


I have seen your code. there is some wrong condition which I have fix and past proper code for your controller.


Code:
$config['upload_path'] = './assets/uploads/';
   $config['allowed_types'] = 'gif|jpg|jpeg|png';
   $this->load->library('upload',$config);
  
   if($this->upload->do_upload())
   {
    $data = array('upload_data' => $this->upload->data());
    
     $this->load->model('artist_model');    
     $uploadedData = $this->upload->data();
     $FileName = $uploadedData[‘file_name’];
     $this->artist_model->addBiography($FileName);
     $this->load->view('addBiography',$data);
  
  
   }else
   if($this->form_validation->run() == FALSE)
   {
   $this->load->view('addBiography');
  
   }else{
    $error = array('error' => $this->upload->display_errors());
    $this->load->view('addBiography', $error);
   }

may that helps.
#8

[eluser]Chilukuri Bhaskar[/eluser]
i am getting following error

view The filetype you are attempting to upload is not allowed.
#9

[eluser]Sanjay Sarvaiya[/eluser]
which types of file you want to upload ?
here you can change
Code:
$config['allowed_types'] = 'gif|jpg|jpeg|png';
#10

[eluser]Chilukuri Bhaskar[/eluser]
Please find complete controller code please help me

<?php

$this->load->library('form_validation');
$this->form_validation->set_rules('name', '', 'trim|required');
$this->form_validation->set_rules('location', '', 'trim|required');
$this->form_validation->set_rules('dob','', 'trim|required|');
$this->form_validation->set_rules('bio', '', 'trim|required');


$config['upload_path'] = './assets/uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$this->load->library('upload',$config);

if($this->upload->do_upload())
{
$data = array('upload_data' => $this->upload->data());

$this->load->model('artist_model');
$uploadedData = $this->upload->data();
$FileName = $uploadedData['file_name'];
$this->artist_model->addBiography($FileName);
$this->load->view('addBiography',$data);


}else
if($this->form_validation->run() == FALSE)
{
$this->load->view('addBiography');

}else{
$error = array('error' => $this->upload->display_errors());
$this->load->view('addBiography', $error);
}





?>




Theme © iAndrew 2016 - Forum software by © MyBB