[eluser]meer[/eluser]
hi every one , im new to codeigniter
i wants to uplad a image and save its file name into the data base
i tried alott bt didnt find out the way
im using the folling codes
Controller
<?php
class Upload extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}
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('upload_form', $error);
}
else
{
$filename = $data['upload_data']['file_name'];
$file_data = file_get_contents($data['upload_data']['file_name']);
$this->load->model('form_model');
$this->form_model->add_data($filename, $file_data, 'ID1');
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
}
?>
Model
<?php
class Form_model extends CI_Model{
function form_model()
{
parent::Model();
}
function add_data($filename, $filedata, $post_id)
{
//(images)...its my table name
$this->db->query("INSERT INTO images SET file_data='$filedata', filename='$filename', postid='$post_id'");
}
}
///////////////////////////////
on execution its showing the blank page
please sum one help me..........
Thanks in advanc
?>