image upload in codeigniter giving error

I am upload an image in one my form but its always giving me an error like

“A PHP Error was encountered Severity: Notice Message:
Undefined index: vimage Filename: controllers/vouchers.php Line
Number: 42”

My View File code :

<?php echo form_open_multipart(site_url("vouchers/add_item/"), array("class" => "form-horizontal","id"=>"addItem")) ?>
<?php echo form_close() ?>

My Controller Code :

if ($_FILES['vimage']['size'] > 0) {
"upload_path" => './uploads/',
"overwrite" => FALSE,
"encrypt_name" => TRUE,
"remove_spaces" => TRUE,
"allowed_types" => "gif|jpg|png|jpeg",

if (!$this->upload->do_upload('vimage')) {
$data = $this->upload->data();
$img = $data['file_name'];

please let me know what i am doing wrong here


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s