[eluser]ColinHoernig[/eluser]
NEW PROBLEM, LAST POST!
So, I have my image upload working with thumbnail creation. This is how i have my upload method setup:
Code:
function _do_upload($field_name) {
$config['upload_path'] = './img/products/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2048';
$config['max_width'] = '1600';
$config['max_height'] = '1200';
$this->load->library('upload', $config);
if(!$this->upload->do_upload($field_name)) {
$error = array('error' => $this->upload->display_errors());
$this->load->view('administration/products/add_product', $error);
} else {
$data = array('upload_data' => $this->upload->data());
$temp = $this->upload->data();
$config['image_library'] = 'GD2';
$config['source_image'] = './img/products/' . $temp['file_name'];
$config['maintain_ratio'] = TRUE;
$config['create_thumb'] = TRUE;
$config['quality'] = '80';
$config['height'] = '100';
$config['width'] = '100';
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$data = array('upload_data' => $this->upload->data());
return $data;
}
}
It works to create the thumbnail and upload the original file, but what I want to do is upload a file, have it resize to set dimensions, and then replace the original file with the resized version.
Is this possible?
Also, is there a better way to get the thumbnail url from the upload? This is what I'm using now (it works but...):
Code:
// CUT OFF
$upload = $this->_do_upload('product_image');
if($upload != NULL) {
$product_image_url = $_FILES['product_image']['name'];
$pos1 = strpos($product_image_url, ".");
$file_type = substr($product_image_url, $pos1);
$product_thumb_url = substr($product_image_url, 0, $pos1);
$product_thumb_url .= "_thumb";
$product_thumb_url .= $file_type;
//CUT OFF
I really appreciate anybodys help
.
So, I have my image upload working with thumbnail creation. This is how i have my upload method setup:
Code:
function _do_upload($field_name) {
$config['upload_path'] = './img/products/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2048';
$config['max_width'] = '1600';
$config['max_height'] = '1200';
$this->load->library('upload', $config);
if(!$this->upload->do_upload($field_name)) {
$error = array('error' => $this->upload->display_errors());
$this->load->view('administration/products/add_product', $error);
} else {
$data = array('upload_data' => $this->upload->data());
$temp = $this->upload->data();
$config['image_library'] = 'GD2';
$config['source_image'] = './img/products/' . $temp['file_name'];
$config['maintain_ratio'] = TRUE;
$config['create_thumb'] = TRUE;
$config['quality'] = '80';
$config['height'] = '100';
$config['width'] = '100';
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$data = array('upload_data' => $this->upload->data());
return $data;
}
}
It works to create the thumbnail and upload the original file, but what I want to do is upload a file, have it resize to set dimensions, and then replace the original file with the resized version.
Is this possible?
Also, is there a better way to get the thumbnail url from the upload? This is what I'm using now (it works but...):
Code:
// CUT OFF
$upload = $this->_do_upload('product_image');
if($upload != NULL) {
$product_image_url = $_FILES['product_image']['name'];
$pos1 = strpos($product_image_url, ".");
$file_type = substr($product_image_url, $pos1);
$product_thumb_url = substr($product_image_url, 0, $pos1);
$product_thumb_url .= "_thumb";
$product_thumb_url .= $file_type;
//CUT OFF
I really appreciate anybodys help
.