title: How to download an uploaded image in PHP Codeigniter
body: <p>I have uploaded an image and then applied rotation operation on the image and fetch the flipped image in other view, now how to download that flipped image please guide me?</p>
  
  <p>View code for uploading image:</p>
  
  <pre><code>&lt;input type='file' name="userfile" size="20"&gt;
  &lt;input type="submit" name="upload" value="Flip"&gt;
  </code></pre>
  
  <p>Controller code for flip:</p>
  
  <pre><code>$data['title'] ='Flip Image';
  $upload['upload_path'] = './assets/images/';
  $upload['allowed_types'] = 'gif|jpg|jpeg|png';
  $this-&gt;load-&gt;library('upload',$upload);
  $filedata1 = $this-&gt;upload-&gt;data();
  if(!$this-&gt;upload-&gt;do_upload('userfile')){
  show_error($this-&gt;upload-&gt;display_errors());
  }           
  $this-&gt;load-&gt;library('image_lib');
  $config['image_library'] = 'gd2';
  $config['source_image'] = $this-&gt;upload-&gt;data('full_path');
  $config['rotation_angle'] ='hor';
  $this-&gt;image_lib-&gt;initialize($config);
  if(!$this-&gt;image_lib-&gt;rotate()){
      show_error($this-&gt;image_lib-&gt;display_errors());
  }
  $filedata = $this-&gt;upload-&gt;data();
  $data['img2'] = base_url().'/assets/images/'.$filedata['file_name'];
  print $this-&gt;load-&gt;view('pages/result',$data,true);
  </code></pre>
  
  <p>Download Function:</p>
  
  <pre><code>$this-&gt;load-&gt;helper('download');
  $data = 'myimag.png';
  force_download($img2, $data);
  redirect('pages/result');
  </code></pre>
  
  <p>Now I am fetching this image result in other page and here I called the download function of controller(given above) on click the download button so that it should start downloading the file without asking the path for it but it is showing error: 
  Result View:</p>
  
  <pre><code>&lt;img src="&lt;?php echo $img2;?&gt;" width="200" height="200"&gt; 
  &lt;?php echo form_open('pages/download()'); ?&gt;
  &lt;input type="submit" name="submit" value="Download"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <blockquote>
    <p>Error:  Too few arguments to function Pages::download(), 0 passed in
    D:\xampp\htdocs\ImageTools\system\core\CodeIgniter.php on line 532 and
    exactly 1 expected</p>
  </blockquote>