Welcome Guest, Not a member yet? Register   Sign In
Problem in uploading image
#1

[eluser]silent_assassin[/eluser]
I m trying to write a simple program that uploads an image to a directory.when i press submit button i get following error message.
Quote:Fatal error: Call to undefined method CI_Upload::insert() in C:\wamp\www\code\system\application\models\post_data.php on line 11
This is my model
Code:
<?php
class Post_data extends Model
{
    function insert()
    {
    $config=array('upload_path'=>'./uploads/',
                       'allowed_types'=>'png|gif|JPG|JPEG|PNG|GIF',
                       'max_size'=>'1000');
    $this->load->library('upload',$config);
    $this->upload->insert();        
    }
  
}
?>
This is my controller
Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();        
    }
    
    function index()
    {
            $this->load->model('post_data');
            $this->load->view('post_view.html');
        
            if($this->input->post('create_product'))
            {
                
                $this->post_data->insert();
            }
            
    }
}
and finally my view
Code:
<html>
    <head></head>
    <body>

<?php $this->load->helper('form'); ?>
<?php  echo form_open_multipart('Welcome'); ?>

   <?php echo form_upload();?>

    <p>
        &lt;?php echo form_submit('create_product', 'Upload image'); ?&gt;
        
    </p>
  
&lt;?php echo form_close(); ?&gt;
    &lt;/body&gt;
&lt;/html&gt;
How to overcome this error?


Messages In This Thread
Problem in uploading image - by El Forum - 07-21-2010, 04:33 AM
Problem in uploading image - by El Forum - 07-21-2010, 06:32 AM
Problem in uploading image - by El Forum - 07-21-2010, 06:39 AM
Problem in uploading image - by El Forum - 07-21-2010, 06:52 AM
Problem in uploading image - by El Forum - 07-21-2010, 06:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB