I\'ve been googling around for 2-3 hours looking at every stackoverflow thread related to this. As far as I can see, lots of people share my frustration. Like many others, I
Using the library Codeigniter ( library upload single file and multi file ) Easily upload .
There is nothing wrong with the code. There was server lag and the folder where the images go wasn't refreshing on its own. Sorry for wasting everyone's time - I did check all of your answers.
I found this in my archive. I don't know if its working. Maybe you want to try it.
<form action="admin/#/add_content/do_upload" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<input type="file" class="mb5" name="userfiles[]" multiple>
</form>
Here is Controller.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Upload extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
$files = $_FILES;
$cpt = count($_FILES['userfile']['name']);
for($i=0; $i<$cpt; $i++)
{
$_FILES['userfile']['name']= $files['userfile']['name'][$i];
$_FILES['userfile']['type']= $files['userfile']['type'][$i];
$_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
$_FILES['userfile']['error']= $files['userfile']['error'][$i];
$_FILES['userfile']['size']= $files['userfile']['size'][$i];
if($this->upload->do_upload()){
echo "File ".$_FILES["userfile"]["name"]. " has been uploaded.\n";
}
else{
//Error. this->upload->display_errors();
}
}
header("Location: http://localhost:82/MyCRM/admin/#/add_content");
}
}