photo upload with codeigniter

Posted on Stack Overflow See other posts from Stack Overflow
Published on 2009-07-23T09:13:05Z Indexed on 2012/09/18 21:38 UTC
Read the original article Hit count: 197

Filed under:
|
|
|

I know there are many tutorials online, but I could not make them work :( maybe something particularly wrong with my system :/

My Controller localpath is: /localhost/rl/applications/backend/controller/

Controller:

function do_upload()
{
	$config['upload_path'] = './uploads/';
	$config['allowed_types'] = 'gif|jpg|png';
	$config['max_size']	= '100';
	$config['max_width']  = '1024';
	$config['max_height']  = '768';

	$this->load->library('upload', $config);

	if ( ! $this->upload->do_upload())
	{
		$error = array('error' => $this->upload->display_errors());

		$this->load->view('add_image', $error);
	}	
	else
	{
		$data = array('upload_data' => $this->upload->data());

		$data['id'] = $this->input->post['id_work'];
		$this->load->view('add_image', $data);
	}

}

My View localpath is: /localhost/rl/applications/backend/view/

View:

echo form_open_multipart('do_upload');	
    <ul class="frm">
    	<li><label>File: *</label><input type="file" name="userfile" class="frmlmnt" size="50" /></li>		
    	<li><label></label><input type="submit" class="btn" value="Upload" /></li>
    </ul>
 </form>

Maybe I do something wrong with path

© Stack Overflow or respective owner

Related posts about image

Related posts about codeigniter