diff --git a/application/config/image_lib.php b/application/config/image_lib.php
new file mode 100644
index 0000000..f4a4a6e
--- /dev/null
+++ b/application/config/image_lib.php
@@ -0,0 +1,10 @@
+ 'gd2',
+ 'create_thumb' => true,
+ 'maintain_ratio' => true,
+ 'width' => 175,
+ 'height' => 175,
+ 'thumb_marker' => '',
+);
+?>
\ No newline at end of file
diff --git a/application/config/upload.php b/application/config/upload.php
new file mode 100644
index 0000000..5bb7ac0
--- /dev/null
+++ b/application/config/upload.php
@@ -0,0 +1,7 @@
+ 2048,
+// 'upload_path' => './uploads/',
+// 'allowed_types' => 'gif|jpg|jpeg|png|bmp'
+// );
+?>
\ No newline at end of file
diff --git a/application/controllers/upload.php b/application/controllers/upload.php
index 762a248..5291275 100644
--- a/application/controllers/upload.php
+++ b/application/controllers/upload.php
@@ -10,24 +10,27 @@ class Upload extends CI_Controller {
$temp_name = md5(rand());
+ // cannot move partial config to config directory with this class?
$config = array(
- 'file_name' => $temp_name,
'max_size' => 2048,
'upload_path' => './uploads/',
'allowed_types' => 'gif|jpg|jpeg|png|bmp'
);
+ // end stuff that should be removed.
+ $config['file_name'] = $temp_name;
- $this->load->library('upload', $config);
+ $this->load->library('upload');
+ $this->upload->initialize($config);
if (!$this->upload->do_upload('image')) {
$message = array('type' => 'error', 'status' => $this->upload->display_errors());
} else {
$upload = $this->upload->data();
- $hash = md5_file($upload['full_path']);
- $width = $upload['image_width'];
- $height = $upload['image_height'];
- $size = $upload['file_size'];
+ $hash = md5_file($upload['full_path']);
+ $width = $upload['image_width'];
+ $height = $upload['image_height'];
+ $size = $upload['file_size'];
$this->load->model('fileupload');
$duplicate = $this->fileupload->check_duplicate($hash);
@@ -35,24 +38,22 @@ class Upload extends CI_Controller {
if($duplicate) {
unlink($upload['full_path']);
- $message = array('type'=>'error', 'status'=>'You are attempting to upload a duplicate of image ' . $duplicate . '.');
+ $message = array(
+ 'type' => 'error',
+ 'status' =>'You are attempting to upload a duplicate of image ' . $duplicate . '.'
+ );
} else {
$file_name = $this->fileupload->add_upload($upload['file_ext'], $upload['client_name'],$width,$height,$size,$hash);
rename($upload['full_path'], $upload['file_path'] . $file_name . $upload['file_ext']);
$config = array(
- 'image_library' => 'gd2',
- 'source_image' => $upload['file_path'] . $file_name . $upload['file_ext'],
- 'create_thumb' => true,
- 'maintain_ratio' => true,
- 'width' => 175,
- 'height' => 175,
- 'new_image' => './thumbs/' . $file_name . $upload['file_ext'],
- 'thumb_marker' => '',
+ 'source_image' => $upload['file_path'] . $file_name . $upload['file_ext'],
+ 'new_image' => './thumbs/' . $file_name . $upload['file_ext'],
);
- $this->load->library('image_lib',$config);
+ $this->load->library('image_lib');
+ $this->image_lib->initialize($config);
$this->image_lib->resize();
$message = array('type'=>'success','status'=>'Uploaded successfully', 'file'=>base_url($file_name));