The Error that your File is not uploading to the provided path is that you have given the relative path for the upload directory
$config['upload_path'] = './assets/images/gambar_paket/';
Hence the realative path is to be replaced with the FCPATH
Here are some of the codes that are to be used.
EXT: The PHP file extension
FCPATH: Path to the front controller (this file) (root of CI)
SELF: The name of THIS file (index.php)
BASEPATH: Path to the system folder
APPPATH: The path to the "application" folder
Hence you have to replace the two line below in your up-loader code:
Replace:
$config['upload_path'] = './assets/images/gambar_paket/';
$this->upload->do_upload();
With:
$config['upload_path'] = FCPATH ."assets/fileupload/";
$this->upload->do_upload('userimage'); // Where userimage is the name of the file uplaoder input type name
HTML will look like this:
<input type="file" name="userimage"/>
And the Entire upload function will look like as follows.
$config['upload_path'] = FCPATH ."assets/images/gambar_paket/";
$config['allowed_types'] = 'gif|jpg|png';
$config['allowed_types'] = 'gif|jpg|png|jpeg|bmp';
$config['max_size'] = 1000;
$config['max_width'] = 1024;
$config['max_height'] = 900;
$config['file_name'] = $file;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('userimage')) {// Here you can handle the Failure Upload}
else
{ $data = $this->upload->data(// Here you can handle the operations after the image is uploaded);}
Here is the sample form that you need to upload the image from the HTML Syntax:
<?php
echo form_open_multipart('employee/addemployee', array('name' => 'addemployee', 'class'=>'form-horizontal'));
?>
<div class="form-group">
<label class="control-label col-sm-4" for="pwd">Profile:</label>
<div class="col-sm-8">
<input type="file" class="" id="profile" name="userimage">
</div>
</div>
<?php
echo form_close();
?>
Note: It will redirect to employee/addemployee which is the Employee Controller and search for function called addemployee and there you have the code to upload the image and then save it using the model.
I hope so this explanation will be clear to understand the Error that you get and to rectify it in further projects that you make on.
Happy Coding:)