So i’m uploading any image file via my great upload form and it uploads it twice (ex. name, name1). Code in the model function responsible for upload below:
function do_upload () {
if(isset($_POST['media'])) {
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png|pdf',
'upload_path' => $this->path;
);
$this->load->library('upload', $config);
$i = 1;
while($i < ($this->input->post('value')+1)) {
$this->upload->do_upload('attachment'.$i);
if(!$this->upload->do_upload('attachment'.$i)) echo $this->upload->display_errors();
echo "added attachment".$i."<br/>";
$i = ++$i;
}
} else { echo "nothing passed"; }
}
in chrome developer tools i see normal post request send with files i upload, but it created them doubled in the folder. any ideas?
cheers!
You call the $this->upload->do_upload method twice in your while loop. Remove the first line before the if statement.