[eluser]chzigkol[/eluser]
Edit: I found that I cannot upload a file via an ajax call. Can you suggest me a plugin that uses jquery library?
When I try to upload an image, I get this error
"You did not select a file to upload."
This is my view:
<div id="picturesContainerCreate">
<?php
$picturesUriFileCreate = array(
'name' => 'pictureuri',
'id' => 'pictureuri',
'value' => set_value('pictureuri')
);
$picturesSubmitCreate = array(
'name' => 'picturesSubmit',
'id' => 'picturesSubmit',
'value' => 'Create Picture',
'content' => 'Upload Picture'
);
?>
<?php echo form_upload($picturesUriFileCreate);?>
<br/>
<?php echo form_submit($picturesSubmitCreate);?>
</div>
And this is the code in my controller:
$config['upload_path'] = $this->config->item('root_url'). 'media/images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '4096';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload()) {
$error = $this->upload->display_errors();
echo $error;
}
else {
$fileInfo = $this->upload->data();
$options['uri'] = $fileInfo['file_name'];
$returnId = $this->Pictures_model->createPictures($options);
echo "The image with the name " . $options['uri'] . " has been successfully uploaded";
}