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 cannot upload an image, even though it shows no errors.
I've literally tried anything and everything I found online, but nothing seems to work...
I can only see the properties of the image with var_dump($_FILES). I want to store the image into a folder and its name into a database.
Controller
function upload_sl()
{
$config['upload_path'] = 'sliki/samurajsliki/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '10000';
$this->load->library('upload', $config);
/*$this->upload->initialize($config);*/
/*var_dump($_FILES);*/
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('samuraj/slikaclen', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('header_samurajmain');
$this->load->view('samuraj/admin_samuraj');
$this->load->view('footer_subpage');
}
}
View
<?php echo $error;?>
<div class="center-block" style="width: 30%; height: 50%; clear:both;">
<?php echo form_open_multipart('admin_page/upload_sl');?>
<input type="file" name="userfile" size="20" />
<br />
<input type="submit" value="Стави нова слика" />
</form>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…