[eluser]JimmyJ[/eluser]
Hey, trying to load a library for image handling, but don't think it's being pulled correctly. The code I have is:
Code:
<?php
//echo $_SERVER['DOCUMENT_ROOT'];
//print_r($_POST);
mysql_query("INSERT INTO gallery (pageID, imageTitle, imageDesc) VALUES ('$_POST[pageID]', '$_POST[imageTitle]', '$_POST[imageDesc]')");
$imageid = mysql_insert_id();
$folder = $_SERVER['DOCUMENT_ROOT'] . 'userFiles/gallery/large/';
$thumbFolder = $_SERVER['DOCUMENT_ROOT'] . 'userFiles/gallery/thumbs/';
//if(!empty($_FILES['userfile'])){ echo '<p style="color:green">file detection successful</p>'; }
//else { echo '<p style="color:red">file failed to upload</p>'; }
move_uploaded_file($_FILES['userfile']['tmp_name'], $folder.$imageid.".jpg");
if(file_exists($folder.$imageid.".jpg"))
{
$this->load->library('image_lib');
// RESIZE
$config[] = 'gd2';
$config['source_image'] = $folder.$imageid.".jpg";
$config['maintain_ratio'] = TRUE;
$config['width'] = 500;
$config['height'] = 400;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
// THUMB
$config[] = 'gd2';
$config['source_image'] = $folder.$imageid.".jpg";
$config['new_image'] = $thumbFolder.$imageid.".jpg";
$config['maintain_ratio'] = TRUE;
$config['height'] = 118;
$config['width'] = 247;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
chmod($folder.$imageid."jpg", 0777);
//CROP THUMB
$config[] = 'gd2';
$config['source_image'] = $thumbFolder.$imageid.".jpg";
$config['x_axis'] = 109;
$config['y_axis'] = 11;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->crop();
}
die("<p>End</p>");
header("location: /admin/pages/modify/$_POST[pageID]");
?>
But this gives the error:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$image_lib
Filename: pages/add-gallery.php
Line Number: 30
Fatal error: Call to a member function clear() on a non-object in D:\Websites\server\www\core\application\views\admin\pages\add-gallery.php on line 30
Does anyone have any ideas to why this would be happening?