Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Multiple uploads + resizing

edited November 2011 in Modules

I've been having issues with uploading images in my model. I have this so far:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Products_model extends Base_module_model {
public $required = array('product_name','product_part_number','product_first_image');
public $image_fields=array('product_first_image_upload','product_second_image_upload',
public $thumb = array("width"=>88,"height"=>88);
public $big = array("width"=>300,"height"=>300);
public $product_path; /* IMAGES UPLOAD TO images/products/ (thumbs/) */

function __construct() {
$this->product_path = realpath(APPPATH . '../images/products');

function form_fields($values=array()) {
$fields = parent::form_fields($values);
//form stuff
return $fields;

function on_after_post($values) {
return $values

Basically, I need to make this so that when the images are sent, the model will, on_after_post, create uniformly sized small and large thumbnails (sent under the names in the var, $image_fields). I've tried everything and I would LOVE any help you could offer.



  • edited 12:02PM
    Have you looked at the projects model in the demo branch:

    It has a lot of that code to taking images and resizing them an placing them into a folder code you will probably need.
  • edited November 2011
    Thanks for getting back to me quickly! That's a great start, but I need to edit (potentially) multiple photos at the same time, am I able to do this with $data = $CI->upload->data();?

    Edit: working brilliantly for one item. Thanks!
  • edited 12:02PM
    The uploaded information is saved on the model in the $this->upload_data property which is an array of all the uploaded files information obtained from $CI->upload->data()
  • edited 12:02PM
    Okay, I'll have a play with this and see how it goes. Thanks again :).
  • edited 12:02PM
    Just getting back to you to confirm that you're a genius. Cheers! Much appreciated.
  • edited 12:02PM
    Glad you got it working!
Sign In or Register to comment.