Welcome Guest, Not a member yet? Register   Sign In
problems with thumb's creation

hi ,am currently using codeigniter 2.o for a project and i have a little problem with thumb creation.i intend to allow users upload picture and have the picture renamed to there last name then have anoda function from within the upload function create a thumbnail then send it to another directory inside the image directory (i named it avatar),.the code does this perfectly,but now i intend to encrypt the last name befor changing the uploaded pic name that is where the problem sets in, the upload is carried out the name is changed but a thumbnail is not created ... please can any one tell me what the problem is here is the code sample

function set_avatar()

            /*check if user is even logged in */

        $last_name=$this->session->userdata('last_name');//this value is encrypted
            /*parse the useful user values to the data array for use on this page */
              $data['user_id']= $user_id;
              $data['email']= $email;
              $data['last_name']= $last_name;
              $data['first_name']= $first_name;
              /*assign an empty value to the error key of the data array to avoid error on the view page*/
              $data['error'] = "";
              /*the directory for uploading the file the number represents a mixture of birth date and month
              af means all files u1 upload 1 avts avatar ..jst a path to make the path undetectable*/
              $dir = "./path/avatar";
              /*preparing the config settings for upload */
              $config['file_name'] = $last_name; // the new file name the image should have
              $config['upload_path'] = $dir; // the directory the image should go to,already specified
              $config['allowed_types'] = 'gif|jpg|png'; // the file types that are allowed
              $config['max_size']    = '10000'; //the maximum image size
              $config['max_width']  = '300'; //the maximum image width
              $config['max_height']  = '230'; // the maximum image height

              $this->load->library('upload', $config); // retrieving the upload library with the specified settings

              /*using the do upload settings upload the file if it fails stop upload and show errors*/
              if ( ! $this->upload->do_upload())
              $data['error'] = $this->upload->display_errors();

              /*else retrieve the upload data from the file uploaded*/
              /*pass all the upload data to the $img_data array*/
              $img_data = $this->upload->data();
              /*the file(image) extension type png or gif or jpg*/
              $img_ext  = $img_data['file_ext'];
              /*thumb name without extension*/
              $thumb = $last_name;
              /*thumb name with extension*/
              $thumb_name = $thumb.$img_ext;
              /*create thumbnail using the thumb nail function*/
              /*record avatar details in the db*/
              $avatar_array = array(
                      "user_id" => $user_id,
                      "avatar" => $thumb,
                      "extension" => $img_ext
              /*start creat session for img_name and ext*/
              $image_session =  array(
              /*redirect to home page*/
              }//end if else $this->upload->do_upload
            }//end check if user is logged in ($this->session->userdata('user_id'))
           }//end if eles user is logged in ($this->session->userdata('user_id'))
    }//end function set avatar

   ///start the create thumb  function this is used in the set avatar function to create the avatar thumb
      function create_thumb($thumb_name)
        /*check if user is logged in*/
          //set the path to were the image is
            $dir = "./path/avatar";
          //set the path to were the thumb should be sent
             $new = "./path/avatar/thumbs";
          //set the configuration to be used for image resizing
              $config['image_library'] = 'gd2';
              $config['source_image'] = $dir;
              $config['new_image'] = $new;
              $config['create_thumb'] = TRUE;
              $config['maintain_ratio'] = TRUE;
              $config['width'] = 35;
              $config['height'] = 50;
         //load the image library for image reszing
              $this->load->library('image_lib', $config);
          //resize image
            }//end if eles user is logged in ($this->session->userdata('user_id'))
            //else redirect to the home page
      }//end function to create

Theme © iAndrew 2016 - Forum software by © MyBB