Welcome Guest, Not a member yet? Register   Sign In
Variables are not passing in view from my controller
#1

(This post was last modified: 03-11-2015, 10:29 PM by dragonabv.)

The Controller:

PHP Code:
class Upload extends CI_Controller
{
    function 
__construct()
    {
        
parent::__construct();
        
$this->load->helper(array('form''url'));
    }

        public function 
do_upload()
        {
        
$config['upload_path'] = './assets/images/uploads/promo/';
        
$config['allowed_types'] = 'jpg|png';
        
$config['max_size']    = '2000';
        
$config['max_width' '3000';
        
$config['max_height' '1768';

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

        if ( !
$this->upload->do_upload())
        {
            
$error = array('error' => $this->upload->display_errors());
            
$data['error'] = $error;
            
$data['data'] = "";    
            
$this->load->view('admin/upload_promo'$data);

        }
        else
        {
            
$data['data'] = array('upload_data' => $this->upload->data());
            
$data['error'] = "";
            
$this->load->view('admin/upload_promo'$data);
        }
        }


The View:

PHP Code:
<?php 
if($data != ""){echo "Image Uploaded Sucessfuly!";}
if(
$error != ""){echo $error;}

 
?>

PHP Code:
<?php echo form_open_multipart('upload/do_upload');?>

Code:
<input type="file" name="userfile" size="20" />

<br /><br />

<input type="submit" value="upload" />

</form>

The Error:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: data

Filename: core/Loader.php(830) : eval()'d code

Line Number: 8



What is the Problem??
Reply


Messages In This Thread
Variables are not passing in view from my controller - by dragonabv - 03-11-2015, 10:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB