EllisLab text mark
Advanced Search
     
how to upload file with CI?
Posted: 14 August 2010 04:53 PM
Joined: 2010-08-14
1 posts

I already did on the tutorial but it show this message please help?
“The upload path does not appear to be valid.”
where is my code in controller/upload.php

<?php
class Upload extends Controller
{
  function Upload()
  {
        parent::Controller();
        $this->load->helper(‘html’);
        $this->load->helper(‘form’);
        $this->load->helper(‘url’); 
        $this->load->library(‘upload’); 
  }
  function index()
  { 
     
      $link = array(
      ‘href’=>‘system/application/views/themes/Sky/sky_css.css’,
      ‘rel’=>‘stylesheet’,
      ‘type’=>‘text/css’
      );
      $data[‘link_css’]=link_tag($link);
      $icon=array(
      ‘href’=>‘system/application/views/themes/Sky/Cresittel.ico’,
      ‘rel’=>‘shortcut icon’,
      ‘type’=>‘image/ico’
      );
      $data[‘myicon’]=link_tag($icon);
     
      $data[‘title’]=‘Uploading file with CodeIgniter Framework’;
      $data[‘Heading’]=‘Upload file’;
      $image_properties = array(
      ‘src’ => ‘system/application/views/themes/Sky/logo.jpg’,
      ‘alt’ => ‘www.cresittel.com’,
      ‘class’ => ‘header-weaper’,
      ‘title’=>‘http://www.cresittel.com’
      );

      $data[‘myimg’]=img($image_properties);
      $data[‘error’]=’‘;
      $this->load->view(‘Upload_view’,$data);
     
     
  }
  function do_upload()
  {
          $link = array(
      ‘href’=>‘system/application/views/themes/Sky/sky_css.css’,
      ‘rel’=>‘stylesheet’,
      ‘type’=>‘text/css’
      );
      $data[‘link_css’]=link_tag($link);
      $icon=array(
      ‘href’=>‘system/application/views/themes/Sky/Cresittel.ico’,
      ‘rel’=>‘shortcut icon’,
      ‘type’=>‘image/ico’
      );
      $data[‘myicon’]=link_tag($icon);
     
      $data[‘title’]=‘Uploading file with CodeIgniter Framework’;
      $data[‘Heading’]=‘Upload file’;
      $image_properties = array(
      ‘src’ => ‘system/application/views/themes/Sky/logo.jpg’,
      ‘alt’ => ‘www.cresittel.com’,
      ‘class’ => ‘header-weaper’,
      ‘title’=>‘http://www.cresittel.com’
      );

      $data[‘myimg’]=img($image_properties);
      $data[‘error’]=’‘;

      $config[‘upload_path’] = “./system/”;
      $config[‘allowed_types’] = ‘gif|jpg|png|jpeg’;
      $config[‘max_size’]  = ‘2048’;
      $config[‘max_width’]  = ‘1024’;
      $config[‘max_height’]  = ‘768’;
     
      $this->load->library(‘upload’, $config);
      if ( ! $this->upload->do_upload())
      {
        $data[‘error’] = $this->upload->display_errors();
       
        $this->load->view(‘upload_view’, $data);
      } 
      else
      {
        $data = array(‘upload_data’ => $this->upload->data());
       
        $data[‘Heading’]=‘Upload File successful ‘;
       
        $this->load->view(‘upload_success_view’, $data);
      }
/*      $this->load->library(‘Multi_upload’);
      $files=$this->multi_upload->go_upload();
 
      if ( ! $files )     
      {
        $data[‘error’] = $this->upload->display_errors();
        $this->load->view(‘Upload_view’, $data);
      } 
      else
      {
        $data = array(‘upload_data’ => $files);
        $data[‘Heading’]=‘Upload File successful ‘;
        $this->load->view(‘upload_success_view’, $data);
      }
*/     
  }
}
?>

 
Posted: 16 August 2010 12:08 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-10-28
181 posts

Did you allow write permissions for the folder you want to upload to?

 Signature 

“Clean, Simple & Elegant Web Design”

 
Posted: 16 August 2010 06:22 AM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-20
170 posts

maybe try the whole serverpath, not just the CI-path