Welcome Guest, Not a member yet? Register   Sign In
how to handle multiple file upload with upload library
#1

[eluser]runrun[/eluser]
Hi guys,



My controller is pretty basic, I just want to see the upload work

Code:
class Fast extends Controller {
    function index()
    {
        $this->load->view('play/fast_view.php');
    }
    function process()
    {
        $config['upload_path'] = '/pic/';
        $config['allowed_types'] = 'gif|jpg|png|jpeg|mp3';
        $config['max_size']    = '0';
        $config['max_width']  = '0';
        $config['max_height']  = '0';
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            $array = array('status'    => 'ierror');
        }    
        else
        {
            $array = array('status'    => 'isuccess');    
        }
        echo json_encode($array);
    }
}

And below is the php the author of the upload script provided, I didn't use it in my controller, because I already utilize the native upload library.

Code:
<?php
$file = $_FILES['file'];
echo '{"name":"'.$file['name'].'","type":"'.$file['type'].'","size":"'.$file['size'].'"}';
?>


Here is my test link http://www.vietnamlist.net/play/fast

The problem: the upload library doesn't save file to designated folder (pic folder). I guess the library was not prepared for multiple files upload or I'm not good enough to make it work ?
#2

[eluser]Federico BaƱa[/eluser]
change $this->upload->do_upload(); for ...do_upload('file')
#3

[eluser]runrun[/eluser]
work beautifully thanks.




Theme © iAndrew 2016 - Forum software by © MyBB