I'm using CI latest version. Got error while uploading a JPG files. I use the code from here https://www.codeigniter.com/userguide3/libraries/file_uploading.html and a little bit from Multiple files upload in Codeigniter
The Controller:
$config = array(
'upload_path' => 'path to upload',
'allowed_types' => 'jpg|gif|png|jpeg',
'overwrite' => 0,
'max_size' => 1024,
);
$this->load->library('upload', $config);
$this->upload->initialize($config); // Make sure it has been initialized
if (!$this->upload->do_upload('gambar1')){
$error = array('error' => $this->upload->display_errors());
return $error;
}else{ echo 'success'; }
The View:
<?php echo form_open(base_url().'report/send', 'method="post" enctype="multipart/form-data"', $hidden);?>
<input type="file" class="hidden" name="gambar1"></form>
When I'm trying to upload JPG files, it gives me The filetype you are attempting to upload is not allowed.
Any idea?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…