[eluser]Yash[/eluser]
May be I'm missing something but it looks some kind of bug to me.
Working Code
Code:
<?php
class Upload extends Controller {
function Upload()
{
parent::Controller();
$this->load->helper(array('form', 'url'));
}
function index()
{
echo realpath('uploads');
$this->load->view('upload/upload_view', array('error' => ' ' ));
}
function do_upload()
{
$config['upload_path'] = realpath('uploads');
$config['allowed_types'] = 'gif|jpg|png|docx|doc|pdf|zip|rar|txt|rtf|psd';
$config['max_size'] = '5000';
$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/upload_view', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload/success_view', $data);
}
}
}
?>
Not working
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' => ' ' ));
echo realpath('uploads') ;
}
function do_upload()
{
$this->load->library('upload');
$config['upload_path'] =realpath('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);
}
}
}