1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Codeigniter Problem With Multiple File Upload

Discussion in 'PHP' started by technoguy, Feb 13, 2013.

  1. #1
    I have made code for the uploading multiple files in the php and its workign fine. But what i need is to implement in the codeigniter. Is it possible to use same code or i have to follow code of the codeigniter? I am good in php but new to codeigniter, please help me to solve this problem.

    Thanks in advance.
    SEMrush
     
    technoguy, Feb 13, 2013 IP
    SEMrush
  2. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #2
    Have you done object oriented PHP code before?

    Basically you can use your code with codeigniter with no problem, it is simply a framework to give you useful functions and classes which you should use if creating a website with the framework.

    You could create a class with the upload function which can then easily be called when uploading needs to be done.

    class SomeClass
    {
        function Upload($params)
        {
            //paste your function and do something with params
        }
    }
    PHP:
     
    Anveto, Feb 13, 2013 IP
  3. webwindow

    webwindow Banned

    Messages:
    83
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    23
    #3
    You would simply initialize the upload library, and call the do_upload() function.

    function do_upload()
    {
      $config['upload_path'] = './uploads/';
      $config['allowed_types'] = 'gif|jpg|png';
      $config['max_size'] = '100';
      $config['max_width'] = '1024';
      $config['max_height'] = '768';
     
      $this->load->library('upload', $config);
     
      if ( ! $this->upload->do_upload())
      {
      $error = array('error' => $this->upload->display_errors());
     
      $this->load->view('upload_form', $error);
      }
      else
      {
        $data = array('upload_data' => $this->upload->data());
        $this->load->view('upload_success', $data);
      }
    } 
    Code (markup):

     
    webwindow, Feb 14, 2013 IP
    starvinmarvin14 and technoguy like this.
  4. ankurTheKing

    ankurTheKing Member

    Messages:
    393
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    35
    #4
    Bro, for security reasons, you should follow codeigniter's syntax.
     
    ankurTheKing, Feb 14, 2013 IP