Welcome Guest, Not a member yet? Register   Sign In
Image upload + resize + store at DB. Some problems
#1

[eluser]bewhite[/eluser]
I'm trying to create script that will process uploading image. This script should resize uploaded item and then store it at the database. Since I don't need file at the filesystem I am trying to rewrite temporary file created by the Apache by the resized image file.
Code:
$file = null;
        if(!empty($_FILES['userfile']['tmp_name']))
        {
          $config = array();
          $config['image_library'] = 'GD';
          $config['source_image'] = $_FILES['userfile']['tmp_name'];
          $config['create_thumb'] = TRUE;
          $config['thumb_marker'] = '';
          $config['maintain_ratio'] = TRUE;
          $config['width'] = 145;
          $config['height'] = 105;
          
          $this->load->library('image_lib', $config);
          $this->image_lib->resize();
          
          $file = file_get_contents($_FILES['userfile']['tmp_name']);
        }
// Write to DB

Something is wrong here because image is at the DB but it have initial sizes. I can't find where is the error. Can anybody help me?
#2

[eluser]gunter[/eluser]
if you set
Code:
$config['create_thumb'] = TRUE;
then the class makes a copy - I believe your copy has the filename FILE_
if you set it to FALSE it resizes the original file...
#3

[eluser]bewhite[/eluser]
[quote author="gunter" date="1198281126"]FILE_[/quote]
Ah. Yes. I have forgot about this character Smile

I have switched 'create_thumb' to the FALSE but the result is the same.

Additionally, I have added error catching block:
Code:
if (!$this->image_lib->resize())
{
  echo $this->image_lib->display_errors('<p>', '</p>');
  exit;
}
No errors were displayed.

Any other ideas?
#4

[eluser]bewhite[/eluser]
BTW, I have tried to run this code both on the GIF and JPG files. The result is the same - nothing.




Theme © iAndrew 2016 - Forum software by © MyBB