i am a beginner at codeigniter. since past 2 days i've been trying to build a file upload system using CI's guide. The problem is that the images are not getting uploaded in the upload directory ./uploads/ I suspect that the problem lies with the permissions of the upload folder but i am not sure. I am building the application locally using XAMPP on Windows 7. after pushing the upload button, nothing happens. (it is supposed to either show display errors or redirect to a success page.)
View- upload_form.php `
<title>Upload Form</title>
</head>
<body>
<form>
<?php
echo $error;
?>
<?php echo form_open_multipart('upload/do_upload'); ?>
<input type='file' name='userfile' size='20' />
<br /><br />
<input type='submit' value='upload' />
</form>
</body>
</html>
success page - upload_success.php
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<h3>Your file was uploaded successfully</h3>
<ul>
<?php foreach ($upload_data as $item => $value): ?>
<li><?php echo $item; ?>: <?php echo $value; ?></li>
<?php endforeach; ?>
</ul>
<p> <?php echo anchor('upload' , 'Upload Another File!'); ?> </p>
</body>
</html>
controller - upload.php
<?php
class Upload extends CI_Controller{
function __construct()
{
parent::__construct();
$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|png|jpg|jpeg' ;
/*$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); //show error page
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success' , $data);
}
}
}
?>
routing - routes.php
$route['default_controller'] = 'welcome';
$route['404_override'] = "";
$route['(:any)'] = "upload";