[eluser]elusid[/eluser]
Hello folks,
I'm a codeigniter noobie and have been smackin' my head on the desk over this one piece of code... I've done my research here and on google,etc looking for a solution to no avail... so essentially what i'm trying to do is upload an image file with a a form and then make a copy of it and resize that image to a thumbnail. The way my code is now i'm not getting any error messages and the upload process seems to work fine. I didnt have GD installed at first and I fixed that and its loading fine after checking phpinfo();
here is my upload controller:
Code:
<?php
class Upload extends Controller {
function Upload()
{
parent::Controller();
$this->load->helper(array('form', 'url'));
}
function index()
{
$data['title'] = "title";
$data['heading'] = "title";
$this->load->view('upload_view', $data, array('error' => ' ' ));
}
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '500';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['remove_spaces'] = 'TRUE';
$config['encrypt_name'] = 'TRUE';
$this->load->library('upload', $config);
//else if loop displays success or error
if ( ! $this->upload->do_upload())
{
$data['title'] = 'Uh Oh! Error Uploading';
$data['heading'] = 'Error Uploading File';
//displays error in heading but too big
//$data['heading'] = $this->upload->display_errors();
//$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_view', $data);
}
else
{
$data = array('upload_data' => $this->upload->data());
//$data['file_name'] = array('upload_data' => 'file_name');
$upload_data = $this->upload->data();
$config['image_library'] = 'gd2';
$config['source_image'] = './uploads/'.$upload_data['file_name'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$data['title'] = "It worked!";
$data['heading'] = 'Success!!';
$this->load->view('success_view', $data);
}
}
}
?>
Any helpful insights will be greatly appreciated. thanks!