
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 1.10 KB | hits: 10 | expires: Never
## Controller
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
$this->load->helper('form');
}
function index()
{
$this->load->view('welcome_message', array('error' => ''));
}
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '100';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('welcome_message', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
var_dump($data);
die();
}
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
## View
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo $error;?>
<?php echo form_open_multipart('welcome/do_upload');?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>
</body>
</html>