Welcome Guest, Not a member yet? Register   Sign In
Array to string conversion
#19

[eluser]Mitja B.[/eluser]
i mean that i want to use model below that i get random uniqe number for image. I call it
but only third image is processed with this library not all pictures. If i use only two pictures then no picture is processed. Is it possible to use it with your code?

Code:
if ( ! $this->upload->do_upload())
      {
         $data['error'] = array('error' => $this->upload->display_errors());
      }  
      else
      {
         $this->Process_image->process_pic();
         $data['upload_data'] = $this->upload->data();
      }



MODEL:

Code:
class Process_image extends Model {
    
    function Process_image()
    {
        parent::Model();
        
        $this->load->library('image_lib');
        //Generate random Activation code
        
        function generate_code($length = 10){
    
                if ($length <= 0)
                {
                    return false;
                }
            
                $code = "";
                $chars = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
                srand((double)microtime() * 1000000);
                for ($i = 0; $i < $length; $i++)
                {
                    $code = $code . substr($chars, rand() % strlen($chars), 1);
                }
                return $code;
            
                }

    }

function process_pic()
    {  
        //Connect to database
        $this->load->database();
        
        //Get File Data Info
        $uploads = array($this->upload->data());
        
        $this->load->library('image_lib');

        //Move Files To User Folder
        foreach($uploads as $key[] => $value)
        {
            
                        //Gen Random code for new file name
            $randomcode = generate_code(12);
            
            $newimagename = $randomcode.$value['file_ext'];
            
            //Creat Thumbnail
            $config['image_library'] = 'GD2';
            $config['source_image'] = $value['full_path'];
            $config['create_thumb'] = TRUE;
            $config['thumb_marker'] = '_tn';
            $config['master_dim'] = 'width';
            $config['quality'] = 75;
            $config['maintain_ratio'] = TRUE;
            $config['width'] = 175;
            $config['height'] = 175;
            $config['new_image'] = '/pictures/'.$newimagename;

            //$this->image_lib->clear();
            $this->image_lib->initialize($config);
            //$this->load->library('image_lib', $config);
            $this->image_lib->resize();
            
            //Move Uploaded Files with NEW Random name
            rename($value['full_path'],'/pictures/'.$newimagename);
            
            //Make Some Variables for Database
            $imagename = $newimagename;
            $thumbnail = $randomcode.'_tn'.$value['file_ext'];
            $filesize = $value['file_size'];
            $width = $value['image_width'];
            $height = $value['image_height'];
            $timestamp = time();
            
            //Add Pic Info To Database
            $this->db->set('imagename', $imagename);
            $this->db->set('thumbnail', $thumbnail);
            $this->db->set('filesize', $filesize);
            $this->db->set('width', $width);
            $this->db->set('height', $height);
            $this->db->set('timestamp', $timestamp);
            
            //Insert Info Into Database
            $this->db->insert('pictures');

        }
        
        
        
    }


Messages In This Thread
Array to string conversion - by El Forum - 07-14-2008, 10:10 AM
Array to string conversion - by El Forum - 07-14-2008, 10:44 AM
Array to string conversion - by El Forum - 07-14-2008, 10:46 AM
Array to string conversion - by El Forum - 07-14-2008, 11:27 AM
Array to string conversion - by El Forum - 07-14-2008, 11:29 AM
Array to string conversion - by El Forum - 07-14-2008, 12:04 PM
Array to string conversion - by El Forum - 07-14-2008, 03:52 PM
Array to string conversion - by El Forum - 07-14-2008, 09:48 PM
Array to string conversion - by El Forum - 07-14-2008, 10:49 PM
Array to string conversion - by El Forum - 07-14-2008, 11:15 PM
Array to string conversion - by El Forum - 07-15-2008, 01:36 AM
Array to string conversion - by El Forum - 07-15-2008, 02:51 AM
Array to string conversion - by El Forum - 07-15-2008, 03:24 AM
Array to string conversion - by El Forum - 07-15-2008, 03:38 AM
Array to string conversion - by El Forum - 07-15-2008, 05:37 AM
Array to string conversion - by El Forum - 07-17-2008, 11:55 AM
Array to string conversion - by El Forum - 07-17-2008, 12:57 PM
Array to string conversion - by El Forum - 07-17-2008, 01:04 PM
Array to string conversion - by El Forum - 07-17-2008, 02:49 PM
Array to string conversion - by El Forum - 07-18-2008, 05:32 AM
Array to string conversion - by El Forum - 07-18-2008, 06:42 AM
Array to string conversion - by El Forum - 07-18-2008, 07:22 AM
Array to string conversion - by El Forum - 08-02-2008, 01:42 PM
Array to string conversion - by El Forum - 09-28-2008, 04:12 AM
Array to string conversion - by El Forum - 02-07-2009, 04:25 PM
Array to string conversion - by El Forum - 04-14-2010, 03:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB