[eluser]Unknown[/eluser]
I have planned to create thumbnails for the photos that I wpload . I am new to codeigniter so I couldn't create one. if anybody could help me Here is my code of the controller file
Code:
[quote]function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->gallery_path = realpath(APPPATH . '../images');
$this->gallery_path_url = base_url().'images/';
}
function index()
{
$this->load->view('gallery');
$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())
{
}
else
{
$upload_data[] = $this->upload->data('full_path');
$this->thumb($upload_data);
}
}
function thumb($upload_data)
{
$config['source_img'] = '$upload_data[file_path]';
$config['new_image'] = $this->gallery_path . '/thumbs';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$this->load->library('image_lib', $config);
if ( ! $this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}
else { echo "sucess";
}
}
}[/quote]
And here is my view file
Code:
[quote]<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo form_open_multipart('images');?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>
</body>
</html>[/quote]
Please help me ???