title: watermark and upload image on codeigniter
body: <p>im trying to watermark my image on codeigniter
  i can watermark image which i have to gave path and that works fine but i want to watermark  my image which im going to upload that means i choose files and watermark them and upload it to database so how can i do that here is my image uploading controller </p>
  
  <p>Controller </p>
  
  <pre><code>function add_page() {
  
      $this-&gt;access_denied();
      //new page add from form process
      if($this-&gt;input-&gt;post('add')) {
  
        $this-&gt;form_validation-&gt;set_rules('slug', 'slug', 'trim|required|min_length[4]|max_length[200]');
        $this-&gt;form_validation-&gt;set_rules('title', 'title', 'trim|required');
        $this-&gt;form_validation-&gt;set_rules('details', 'details', 'trim|required');
        if ($this-&gt;form_validation-&gt;run()) {
  
          $slug = strip_tags(url_title($this-&gt;input-&gt;post('slug')));
          $title = $this-&gt;input-&gt;post('title');
          $details = $this-&gt;input-&gt;post('details');
          $publish_date = time();
          $added_by = $this-&gt;session-&gt;userdata('full_name');
  
  
          // if image is uploaded
          if (isset($_FILES['userfile']['name']) &amp;&amp; $_FILES['userfile']['size']&gt;0) {
  
            $config = array('upload_path' =&gt; './uploads/page/',
                            'allowed_types' =&gt; 'jpg|gif|png|jpeg|ico',
                            'max_size' =&gt; 0,
                            'max_height' =&gt; 0,
                            'max_width' =&gt;0
                          );
            $this-&gt;load-&gt;library('upload', $config);
  
            if ($this-&gt;upload-&gt;do_upload()) {
              $image_files = $this-&gt;upload-&gt;data();z
              $this-&gt;page_model-&gt;add_page($slug, $title, $details, $image_files['file_name'], $publish_date, $added_by);
              $this-&gt;session-&gt;set_flashdata('error_msg', '&lt;div class="alert alert-success" role="alert") New page has been added successfully.&lt;/div&gt;');
              redirect('page/manage-page');
            }
            else {
              $this-&gt;session-&gt;set_flashdata('error_msg', $this-&gt;upload-&gt;display_errors());
              redirect('page/add_page');
            }
  
          }
          else {
            $this-&gt;page_model-&gt;add_page($slug, $title, $details, null,$publish_date,$added_by);
            $this-&gt;session-&gt;set_flashdata('error_msg', '&lt;div class="alert alert-success" role="alert") New page has been added successfully.&lt;/div&gt;');
            redirect('page/manage-page');
          }
        }
  
  
      }
      $data = array('page_title' =&gt; "Add new page",
                    'keywords' =&gt;"",
                    'description' =&gt; "",
                    'image' =&gt; "",
                    'url'=&gt; "",
                    'author' =&gt; "",
                    'page_content' =&gt; $this-&gt;load-&gt;view('page/add', '', true)
                  );
      $this-&gt;load-&gt;view('dashboard', $data);
    }
  </code></pre>
  
  <p>i hope it wont freak you out guys but it would be great help for me thanks.</p>