Welcome Guest, Not a member yet? Register   Sign In
imagecopy() expects parameter 1 to be resource, boolean given
#1

(This post was last modified: 02-08-2017, 05:29 AM by shihasck.)

I'm calling this do_upload_img() function only if there is some input value. And if there is an input value this warning is not there. But when the value is not there, then this warning is displaying.

Here is my code:

Code:
if($_FILES['portfolioimg']['size'])
{
  $portfolioimg = $this->do_upload_img();
}

Here is the do_upload_img function:  


Code:
   function do_upload_img()
   {
       if(isset($_FILES['portfolioimg']['size']) != 0){
          $name_array = array();
          $files = $_FILES;
          $cpt = count($_FILES['portfolioimg']['name']);

          // $config['source_image'] = ''; //get original image
          $config['wm_type'] = 'overlay';
          $config['wm_overlay_path'] = './assets/img/watermark.png';
          $config['quality'] = 50;
          $config['wm_vrt_alignment'] = 'middle';
          $config['wm_hor_alignment'] = 'center';
          // $this->load->library('image_lib', $config);

          for($i=0; $i<=$cpt-1; $i++)
          {          
              $_FILES['userfile']['name']= $files['portfolioimg']['name'][$i];
              $_FILES['userfile']['type']= $files['portfolioimg']['type'][$i];
              $_FILES['userfile']['tmp_name']= $files['portfolioimg']['tmp_name'][$i];
              $_FILES['userfile']['error']= $files['portfolioimg']['error'][$i];
              $_FILES['userfile']['size']= $files['portfolioimg']['size'][$i];    

              $imgnam = rand(10,1000000);
              $ext = pathinfo($files['portfolioimg']['name'][$i], PATHINFO_EXTENSION);
              if($this->upload->initialize($this->set_upload_options($imgnam))){
                  $data = $this->upload->do_upload();
                  $config['source_image'] = './assets/portfolio_img/' . 'Sooo_'.$imgnam.'.'.$ext;
                  $this->image_lib->initialize($config);
                  $this->image_lib->watermark();
                  $name_array[] = $this->upload->data('file_name');
              } else {
                  $this->session->set_flashdata('falsemsg','Only jpg, jpeg, png files are allowed to be uploaded.');
              }
             
          }
          return $name_array;
       }else{
         return false;
       }
   }

Stack overflow Question
Reply




Theme © iAndrew 2016 - Forum software by © MyBB