I have spent days trying to make this work based on the examples in the documentation but I am missing something or I am just STUPID!
I have a CMS application where users upload an image for display in a very fixed layout. We do not want to limit the file size of the uploaded image but would rather "process" it after it arrives.
The image needs to be 615px wide but some of the images uploaded directly from digital cameras are 2500X2000 and bigger so this is CRITICAL.
I pieced together the code from the manual and the image is successfully being uploaded to a folder within the CMS app. However, the image is NOT being resized.
If I ever get it to re-size, my plan is to present the image to the user for cropping using jCrop (the final image HAS to be 615X275 and it probably has to be cropped for height after resizing) and then use codeigniter to FTP the image to their site's amenities folder using the original name.
I will appreciate any help in this matter!
Here's my code:
function do_feature_upload() { $imageName = $this->uri->segment(3); //echo $imageName; // Where the file is going to be placed $config['upload_path'] = "./uploads/".$_SESSION['dbPropNumber']; $config['allowed_types'] = 'jpg|jpeg'; $config['max_size'] = '0'; $config['file_name'] = $imageName.'.jpg'; $config['overwrite'] = 'TRUE'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $error['propertyDropdown'] = $_SESSION['propertyDropdown']; $error['username'] = $_SESSION['username']; $error['dbPropNumber'] = $_SESSION['dbPropNumber']; $error['propertyName'] = $this->content->getPropertyName($_SESSION['dbPropNumber']); $this->load->view('upload_AmenityImage', $error); } else { $image_data = $this->upload->data(); $origWidth = $image_data['image_width']; $origHeight = $image_data['image_height']; $newWidth = 615; $newHeight = $newWidth*$origHeight/$origWidth; $resize = array( 'image_library'=>'gd2', 'source_image'=>base_url().'uploads/'.$_SESSION['dbPropNumber'].'/'.$imageName.'.jpg', 'new_image'=>base_url().'uploads/'.$_SESSION['dbPropNumber'].'/'.$imageName.'1.jpg', 'create_thumb' => FALSE, 'maintain_ratio'=>FALSE, 'width'=>$newWidth, 'height'=>$newHeight ); $this->load->library('image_lib',$resize); $this->image_lib->resize(); $data = array('upload_data' => $this->upload->data()); $data['propertyDropdown'] = $_SESSION['propertyDropdown']; $data['username'] = $_SESSION['username']; $data['dbPropNumber'] = $_SESSION['dbPropNumber']; $data['propertyName'] = $this->content->getPropertyName($_SESSION['dbPropNumber']); //Present jCrop option after image is resized // FTP to final destination $this->load->view('upload_success', $data); } // end if } // end function