Welcome Guest, Not a member yet? Register   Sign In
uploading
#4

[eluser]diasansley[/eluser]
Here is the controller

Code:
<?php

class Upload extends Controller {
    
    function Upload()
    {
        parent::Controller();
        $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
        {
            $data = array('upload_data' => $this->upload->data());
            $this->load->view('upload_success', $data);
        }
    }    
}
?>

the view

Code:
<html>
<head>
<title>Upload Form</title>
</head>
<body>

<?php echo $error;?>

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

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

<br /><br />

&lt;input type="submit" value="upload" /&gt;

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
uploading - by El Forum - 11-23-2010, 10:35 PM
uploading - by El Forum - 11-23-2010, 11:34 PM
uploading - by El Forum - 11-23-2010, 11:39 PM
uploading - by El Forum - 11-23-2010, 11:55 PM
uploading - by El Forum - 11-24-2010, 12:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB