Created
July 31, 2012 05:58
-
-
Save adityamenon/3214128 to your computer and use it in GitHub Desktop.
Codeigniter upload a dynamic number of files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if(!defined('BASEPATH')) exit("No direct script access allowed."); | |
class Upload_test extends CI_Controller { | |
public function index() { | |
if($this->input->post('submit')) { | |
$config['upload_path'] = BASEPATH.'../uploads'; | |
$config['allowed_types'] = 'txt'; | |
$this->load->library('upload', $config); | |
if(empty($_FILES) { | |
//redirect or do something else to stop execution | |
} | |
foreach ($_FILES as $key => $value) { //THIS IS THE CRUCIAL PART | |
$this->upload->do_upload($key); | |
var_dump($this->upload->data()); | |
var_dump($this->upload->display_errors()); | |
} | |
exit(); | |
} | |
$this->load->helper('form'); | |
$this->load->view('upload_test'); | |
} | |
//I have no idea why more complex code exists for the same thing elsewhere on the 'net! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@adityamenon Aha, I came here from a reshare on G+, not because I'm interested in CI itself :)