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
Hey,

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',
'product_third_image_upload','product_fourth_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() {
parent::__construct('fuel_products');
$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.

Cheers.

Comments

  • edited 10:05PM
    Have you looked at the projects model in the demo branch:
    https://github.com/daylightstudio/FUEL-CMS/tree/demo

    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 10:05PM
    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 10:05PM
    Okay, I'll have a play with this and see how it goes. Thanks again :).
  • edited 10:05PM
    Just getting back to you to confirm that you're a genius. Cheers! Much appreciated.
  • edited 10:05PM
    Glad you got it working!
Sign In or Register to comment.