I am trying Codeigniter Email Class but it is not working or May be, I am making mistakes with configuration or something else. please fix it and inform me someone what I should do. I am having a problem with the codeigniter email class.
This is the screenshot after sending the form data to the controller.
View:
<h4>Send Your Feedback</h4>
<form action="<?php echo base_url('front/feedBack') ?>" enctype="multipart/form-data" method="post" class="form-horizontal">
<div class="form-group">
<label for="Name" class="col-sm-3 control-label">Name<span>*</span></label>
<div class="col-sm-9">
<input type="text" name="senderName" class="form-control" id="Name" placeholder="Name">
</div>
</div>
<div class="form-group">
<label for="Phone" class="col-sm-3 control-label">Phone no<span>*</span></label>
<div class="col-sm-9">
<input type="text" name="senderPhone" class="form-control" id="Phone" placeholder="Phone no">
</div>
</div>
<div class="form-group">
<label for="Email" class="col-sm-3 control-label">Email<span>*</span></label>
<div class="col-sm-9">
<input type="text" name="senderEmail" class="form-control" id="Email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="Subject" class="col-sm-3 control-label">Subject</label>
<div class="col-sm-9">
<input type="text" name="senderSubject" class="form-control" id="Subject" placeholder="Subject">
</div>
</div>
<div class="form-group">
<label for="Message" class="col-sm-3 control-label">Message<span>*</span></label>
<div class="col-sm-9">
<textarea name="senderMsg" class="form-control" id="Message" cols="30" rows="5" placeholder="Message"></textarea>
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-sm-3 control-label"></label>
<div class="col-sm-9">
<button type="submit" class="btn btn-default btn-lg btn-block">Send Message</button>
</div>
</div>
</form>
Controller:
public function feedBack()
{
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'host8.registrar-servers.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '30';
$config['smtp_user'] = 'info#dewbn.com';
$config['smtp_pass'] = 'myPass';
$config['charset'] = 'utf-8';
$config['crlf'] = '\r\n'; //should be "\r\n"
$config['newline'] = '\r\n'; //should be "\r\n"
$config['mailtype'] = 'html'; // or html
$config['validation'] = TRUE; // bool whether to validate email or not
$this->email->initialize($config);
$senderName = $this->input->post('senderName');
$senderPhone = $this->input->post('senderPhone');
$senderEmail = $this->input->post('senderEmail');
$senderSubject = $this->input->post('senderSubject');
$senderMsg = $this->input->post('senderMsg');
$this->email->from($senderEmail, $senderName);
$this->email->to('bablukpik#gmail.com');
$this->email->subject($senderSubject);
$this->email->message($senderMsg);
if($this->email->send()) {
echo "Success!";
//return true;
} else {
echo "Failure!";
//return false;
}
}
Try this :
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'test1#gmail.com',
'smtp_port' => 2525,
'smtp_user' => 'gmailusername',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$THIS->email->initialize($config);
$THIS->email->set_newline("\r\n");
$body = str_replace(array('{LOGO_IMAGE}'),array($logo_image),$body);
$body.= email_footer();
$body = '<div style="width:700px;float:left;">'.$body.'</div>';
if (!empty($from))
{
$from_name = !empty($from_name) ? $from_name : SITE_NAME;
$from = !empty($from) ? $from : 'noreply#test.com';
$THIS->email->from($from, $from_name);
}
else
{
$THIS->email->from('noreply#test.com', $from_name);
}
if (!empty($to))
{
$THIS->email->to($to);
}
if (!empty($cc))
{
$THIS->email->cc($cc);
}
if (!empty($bcc))
{
$THIS->email->cc($bcc);
}
$THIS->email->subject($subject);
$THIS->email->message($body);
if (!empty($attachment))
{
if (is_array($attachment))
{
foreach ($attachment as $val)
{
$THIS->email->attach($val);
}
}
else
{
$THIS->email->attach($val);
}
}
if ($THIS->email->send())
{
return TRUE;
}
else{
echo $THIS->email->print_debugger();
exit;
}
Mark it accepted if it works.
Related
i make a table post and i have a field email_id to foreign key with user id and i make some Added posting, my question is how i can added automaticly the email_id from who the user session posting it.. i have tried 2 days and the post can be post but the email_id not automaticly get the data from who posting it..
<?php echo form_open_multipart('user/addpost'); ?>
<div class="modal-body">
<div class="form-group">
<input type="text" class="form-control" id="namaFes" name="namaFes" placeholder="Nama Festival">
</div>
<div class="form-group">
<select name="daerah_id" id="daerah_id" class="form-control">
<option value="">Pilih Daerah</option>
<?php foreach ($nm_daerah as $nm) : ?>
<option value="<?= $nm['id_daerah']; ?>"><?= $nm['nm_daerah']; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<input type="date" class="form-control" id="tanggal" name="tanggal" placeholder="Tanggal Festival">
</div>
<div class="form-group">
<textarea style="height: 80px;" class="form-control" id="deskripsi" name="deskripsi" placeholder="Keterangan"></textarea>
</div>
<div class="form-group">
<input type="text" class="form-control" id="email_id" name="email_id" value="<?= $user['email']; ?>" readonly>
<!--<div class=" form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="1" name="isActive" id="isActive" checked>
<label class="form-check-label" for="isActive">
Is it active?
</label>
</div>
</div>-->
<div class="custom-file">
<input type="file" class="custom-file-input" id="image" name="image">
<label class="custom-file-label" for="image">Choose 1:1 image...</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Add</button>
<? echo form_close(); ?>
this my addedpost.php
$data['title'] = 'Add Posting';
$data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();
$data['nm_daerah'] = $this->db->get('daerah')->result_array();
$data['postfes'] = $this->db->get('postfes')->row_array();
$this->load->model('PostModel', 'post');
$data['postFes'] = $this->post->getPostModel4();
$this->form_validation->set_rules('namaFes', 'Nama Festival', 'required|trim');
$this->form_validation->set_rules('daerah_id', 'Nama Daerah', 'required|trim');
$this->form_validation->set_rules('tanggal', 'Tanggal', 'required|trim');
$this->form_validation->set_rules('deskripsi', 'Deskripsi', 'required|trim');
if ($this->form_validation->run() == false) {
$this->load->view('templates/user-header', $data);
$this->load->view('templates/user-sidebar', $data);
$this->load->view('templates/user-topbar', $data);
$this->load->view('user/addpost', $data);
$this->load->view('templates/user-footer');
} else {
$namaFes = $this->input->post('namaFes');
$daerah = $this->input->post('daerah_id');
$tanggal = $this->input->post('tanggal');
$desk = $this->input->post('deskripsi');
$idpost = $this->input->post('email_id');
$image = $_FILES['image'];
if ($image = '') {
} else {
$config['upload_path'] = './assets/img/posting/';
$config['allowed_types'] = 'jpg|gif|png|jpeg';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('image')) {
echo 'failed upload image';
die();
} else {
$image = $this->upload->data('file_name');
}
}
$data = [
'namaFes' => $namaFes,
'daerah_id' => $daerah,
'tanggal' => $tanggal,
'deskripsi' => $desk,
'email_id' => $idpost,
'image' => $image
];
$this->db->insert('postfes', $data);
$this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Please wait admin approve your post</div>');
redirect('user/addpost');
}
}
and this my model and controller i join it
<input type="text" class="form-control" id="email_id" name="email_id" value="<?= $user['email']; ?>" readonly>
you email show and email against email_id post on controller page.
you can use on view page this:
<input type="text" class="form-control" id="email" name="email" value="<?= $user['email']; ?>" readonly>
<input type="hidden" class="form-control" id="email_id" name="email_id" value="<?= $user['email_id']; ?>">
and then on controller page:
$emailpost = $this->input->post('email');
$idpost = $this->input->post('email_id');
$data = [
'namaFes' => $namaFes,
'daerah_id' => $daerah,
'tanggal' => $tanggal,
'deskripsi' => $desk,
'email_id' => $idpost,
'email' => $emailpost,
'image' => $image
];
Please replace these code and your issue resolved.
I´m trying to apply Firebase to the Admin HTML template that I found yesterday.
In the register page when I click on Sign in it reload the page instead of do the Firebase createUserWithEmailAndPass process.
This is my HTML code:
<form [formGroup]="form" (submit)="registrar(form.value)" class="form-horizontal">
<div class="form-group row" [ngClass]="{'has-error': (!name.valid && name.touched), 'has-success': (name.valid && name.touched)}">
<label for="inputName3" class="col-sm-2 control-label">Nombre</label>
<div class="col-sm-10">
<input [formControl]="name" type="text" class="form-control" id="inputName3" placeholder="Nombre completo">
</div>
</div>
<div class="form-group row" [ngClass]="{'has-error': (!email.valid && email.touched), 'has-success': (email.valid && email.touched)}">
<label for="inputEmail3" class="col-sm-2 control-label">NIF</label>
<div class="col-sm-10">
<input [formControl]="email" type="text" class="form-control" id="inputEmail3" placeholder="NIF/DNI">
</div>
</div>
<div class="form-group row" [ngClass]="{'has-error': (!password.valid && password.touched), 'has-success': (password.valid && password.touched)}">
<label for="inputPassword3" class="col-sm-2 control-label">Contraseña</label>
<div class="col-sm-10">
<input [formControl]="password" type="password" class="form-control" id="inputPassword3" placeholder="Introduce una contraseña">
</div>
</div>
<div class="form-group row" [ngClass]="{'has-error': (!repeatPassword.valid && repeatPassword.touched), 'has-success': (repeatPassword.valid && repeatPassword.touched)}">
<label for="inputPassword4" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<input [formControl]="repeatPassword" type="password" class="form-control" id="inputPassword4" placeholder="Repite la contraseña">
<span *ngIf="!passwords.valid && (password.touched || repeatPassword.touched)" class="help-block sub-little-text">Las contraseñas no coinciden.</span>
</div>
</div>
<div class="form-group row">
<div class="offset-sm-2 col-sm-10">
<button [disabled]="!form.valid" type="submit" class="btn btn-default btn-auth">Confirmar registro</button>
</div>
</div>
</form>
And this my functions:
nuevoUsuario(email, password) {
console.log(email);
return this.af.auth.createUser({
email: email,
password: password
});
}
public registrar(datos: Object): void {
this.submitted = true;
if (this.form.valid) {
// your code goes here
const formarCorreo = this.email.value +' #maimona.com';
console.log(formarCorreo);
this.afService.nuevoUsuario(formarCorreo.toLowerCase,
this.password).then((user) => {
this.afService.saveUserInfoFromForm(formarCorreo.toLowerCase,
this.name, this.email).then(() => {
// this.router.navigate(['login']);
})
.catch((error) => {
this.error = error;
console.log(error);
});
})
.catch((error) => {
this.error = error;
console.log(error);
});
}
}
I don´t know why when I press "Confirmar registro" it reload the page instead of do the function. Well it enter the function until
console.log(formarCorreo);
You can change the type of the button to button from submit and add the function to the buttons click
<button [disabled]="!form.valid" class="btn btn-default btn-auth"
type="button" <-- type
(click)="registrar(form.value)" <--click
>Confirmar registro</button>
type="submit will make elements to reload the form
By default, html <form> elements navigate to their target attribute.
To override this (since this is what you'll want most of the time in a single-page app), angular provides the (ngSubmit) convenience event (which uses event.preventDefault(), which would solve your case anyway, but is cleanear)
<button type="submit"> is doing HTTP request to the server. It's the same like <input type="submit">.
You can change it to ordinary <button> or prevent the submitting a form using events.
I wanted to fix my html/bootstrap style,but at the moment when I clicked the event all my imputs are out of range as picture number 1 at the moment when I get some input wrong . however I want to fix my inputs and when I click my event and get error from jquery stay on the same place as the picture 2
html
<form id="new_product">
<div class="form-group">
<label for="description">Name: </label>
<input type="text" class="form-control" id="description" name="description" title="product description" required>
</div>
<div class="form-group form-inline">
<div class="form-group">
<div class="col-md-5">
<label for="cost_price">Cost Price: </label>
<input type="text" class="form-control" id="cost_price" name="cost_price" title="cost_price" required>
</div>
</div>
<div class="form-group">
<div class="col-md-5">
<label for="selling_price">Selling price: </label>
<input type="text" class="form-control" id="selling_price" name="selling_price" title="selling_price" required>
</div>
</div>
</div>
<div class="form-group form-inline">
<div class="form-group">
<div class="col-md-5">
<label for="wprice">Wholeprice: </label>
<input type="text" class="form-control" id="wprice" name="wprice" title="wprice" required>
</div>
</div>
<div class="form-group">
<div class="col-md-5">
<label for="min_stock">Min stock: </label>
<input type="text" class="form-control" id="min_stock" name="min_stock" title="min_stock" required>
</div>
</div>
<div class="form-group">
<div class="col-md-5">
<label for="stock">Stock: </label>
<input type="text" class="form-control" id="stock" name="stock" title="stock" required>
</div>
</div>
<div class="form-group">
<div class="col-md-5">
<label for="max_stock">Max stock: </label>
<input type="text" class="form-control" id="max_stock" name="max_stock" title="max_stock" required>
</div>
</div>
</div>
</form>
form_view
form_view2
jquery validation
$('#add').on('click',function(){
$("#description").mask("(999) 999-9999");
$("#new_product").validate();
BootstrapDialog.show({
type: BootstrapDialog.TYPE_PRIMARY,
message: function(dialog) {
var $message = $('<div></div>');
var pageToLoad = dialog.getData('pageToLoad');
$message.load(pageToLoad);
return $message;
},
data: {
'pageToLoad': URL_GET_VIEW_PRODUCT
},
closable: false,
buttons:[{
id: 'btn-ok',
cssClass: 'btn-primary',
icon: 'glyphicon glyphicon-send',
label: ' Save',
action: function (e) {
var description = $('#description').val();
var cost_price = $('#cost_price').val();
var selling_price = $('#selling_price').val();
var wprice = $('#wprice').val();
var min_stock = $('#min_stock').val();
var stock = $('#stock').val();
var max_stock = $('#max_stock').val();
if($("#new_product").valid()){
$.ajax({
url: URL_GET_ADD_PRODUCT,
type: 'POST',
data: {description: description, cost_price: cost_price, selling_price: selling_price, wprice: wprice, min_stock: min_stock, stock: stock, max_stock: max_stock}
}).done(function (data) {
console.log(data);
if (data.msg == 'successfully added') {
$('#new_product')[0].reset();
table.ajax.reload();
}else if(data.min_stock == 'el stock no puede ser mayor al min'){
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
message: 'el stock no puede ser mayor al min'
});
}
});
return false;
}
}
},{
id: 'btn-cancel',
cssClass: 'btn-danger',
icon: 'glyphicon glyphicon-remove',
label: ' Cancel',
action: function (e) {
e.close();
}
}]
});
});
I can record data in my db but ajax loading doesn't inter in success method. What's the problem?
error: "SyntaxError: Unexpected end of JSON input
at Object.parse (native)
at n.parseJSON "
record_data.php
<?php
$type=getPar_empty("type",$_GET,"");
$new_nome=$_GET['new_nome'];
$new_cognome=$_GET['new_cognome'];
$new_email=$_GET['new_email'];
$new_lingua=$_GET['new_lingua'];
if ($type=="add_user"){
$stmt=null;
$stmt=$db->prepare("INSERT INTO newsletter_utenti(email,abilitato,nome,cognome,lingua,lista,data_creazione,unsubscribe) VALUES('$new_email',1,'$new_nome','$new_cognome','$new_lingua','manual',now(),0)");
if (!$stmt) {
log_msg($db->error);
die();
}
$stmt->execute();
$stmt->close();
$db->close();
}
?>
script
$("#salvaBtn").click(function(){
var nome = $('#nome').val();
var cognome = $('#cognome').val();
var email = $('#email').val();
var lingua = $('#lingua').val();
var dataString = 'nome='+nome+'&cognome='+cognome+'&email='+email+'&lingua='+lingua+'&type=add_user';
$.ajax({
type:'GET',
data:dataString,
url:"record_data.php",
success:function(result) {
$("#status_text").html(result);
$('#nome').val('');
$('#cognome').val('');
$('#email').val('');
},
error:function(xhr,status,error) {
console.log(error);
}
});
});
$('#adduser').submit(function (){
return false;
});
form
<form name="adduser" id="adduser" method="GET" action="#">
<div class="col-md-3">
<div class="form-group m-b-30">
<p>E-mail</p>
<input class="form-control" type="email" id="email" name="email" placeholder="indirizzo e-mail" email required>
</div>
</div>
<div class="col-md-3">
<div class="form-group m-b-30">
<p>Nome</p>
<input class="form-control" type="text" id="nome" name="nome" placeholder="nome">
</div>
</div>
<div class="col-md-3">
<div class="form-group m-b-30">
<p>Cognome</p>
<input class="form-control" type="text" id="cognome" name="cognome" placeholder="cognome">
</div>
</div>
<div class="col-md-3">
<div class="form-group m-b-30">
<p>Lingua</p>
<select class="form-control" id="lingua" name="lingua">
<option value="it">IT</option>
<option value="en">EN</option>
</select>
</div>
<input type="submit" class="btn btn-embossed btn-primary m-r-20" id="salvaBtn" value="Aggiungi utente"></input>
<div id="status_text" /></div>
</div>
</form>
Your ajax method is POST, but you try to recive values from GET, could be this.
Another way is to use json_decode, from PHP.
$vars = json_decode($_POST['data']);
tell us, these changes will clear your code input.
thanks
hello I'm try to insert file in database but don't working
file which I'm upload gives the value 0 in my coloumn lampiran in database
and not file in folder to store my upload
database
id|npp|tgl_pengajuan|ket|status|lampiran|lama|tgl_mulai|tgl_selesai | id_jenis
controller
class Cutidiluar extends CI_Controller {
var $limit=10;
var $offset=10;
var $gallery_path;
var $gallery_path_url;
public function __construct(){
parent::__construct();
$this->gallery_path = realpath(APPPATH . '../asset');
$this->gallery_path_url = base_url().'asset/';
} public function add()
{ if($this->session->userdata('LOGIN')=='TRUE')
{
$this->load->library('form_validation');
$this->load->model('Diluartahunan_Model');
//load uploading file library
$config['upload_path'] = './asset/';
$config['allowed_types'] = 'jpg|png|pdf|jpeg|word';
$this->load->library('upload',$config);
$this->upload->do_upload();
$this->upload->data();
$this->form_validation->set_rules('ket', 'ket');
$this->form_validation->set_rules('lama', 'lama');
$this->form_validation->set_rules('lampiran', 'lampiran');
if ($this->form_validation->run() == false) {
$data['nama'] = $this->Diluartahunan_Model->nama();
$data['view'] = 'Cutidiluar/add';
$data['judul']='';
$this->load->view('index',$data);
}else {
$this->load->model('Cutidiluar_Model');
$this->Cutidiluar_Model->add();
redirect('Cutidiluar');
} }}
Model
public function add() {
$npp = $this->session->userdata('NPP');
$id_jenis = $this->input->post('id_jenis');
$ket = $this->input->post('ket');
$lama = $this->input->post('lama');
$tgl_selesai= date('Y-m-d',strtotime($this->input->post('tgl_selesai')));
$tgl_mulai= date('Y-m-d', strtotime($this->input->post('tgl_mulai')));
$lampiran = $this->input->post('lampiran');
$data = array(
'npp'=> $npp,
'id_jenis'=> $id_jenis,
'tgl_pengajuan' => date('y-m-d'),
'ket' => $ket,
'status' => 'P',
'lampiran'=> $lampiran,
'lama'=> $lama,
'tgl_mulai'=> $tgl_mulai,
'tgl_selesai'=> $tgl_selesai,);
$this->db->insert('Cuti_diluar', $data);}
view
<link rel="stylesheet" href="<?php echo base_url();?>css/themes/jquery.ui.all.css" type="text/css" />
<script>
$(document).ready(function() {
$( ".datepicker" ).datepicker();
});
function save(){
$.ajax({
url:'<?php echo base_url(); ?>Cutidiluar/add/',
type:'POST',
data:$('#frmsave').serialize(),
success:function(data){
if(data!=''){
$( "#infodlg" ).html(data);
$( "#infodlg" ).dialog({ title:"Info...", draggable: false});
} else {
window.location="<?php echo base_url() ?>Cutidiluar";
} } }); }
function confirmdlg(){
$("#confirm").dialog({
resizable: false,
modal: true,
title:"Info...",
draggable: false,
width: 'auto',
height: 'auto',
buttons: {
"Ya": function(){
save();
$(this).dialog("close");
window.location="<?php echo base_url() ?>Cutidiluar";
},
"Tutup": function(){
$(this).dialog("close");
}
}
});
}
</script>
<div class="span6">
<div class="well grey">
<div class="well-header">
<h5>Tambah Cuti </h5>
</div>
<div class="well-content no-search">
<form id="frmsave" name="frmsave" class="form-validate" >
<form id="frmsave" name="frmsave" class="form-validate">
<h3>Detail </h3>
<div class="form_row">
<label class="field_name">Pilih cuti</label>
<div class="field">
<?php foreach ($nama->result() as $valnama) { ?>
<input type="radio" name="id_jenis" value="<?php echo $valnama->id_jenis; ?>"> <?php echo $valnama->nama ?></br></br> <?php } ?>
</div>
</div>
<div class="form_row">
<label class="field_name">Tanggal Pengambilan Cuti</label>
<div class="field">
<input placeholder="TANGGAL MULAI CUTI" class="datepicker" size="16" type="text" name="tgl_mulai" id="tgl_mulai" value="<?php echo set_value('tgl_mulai'); ?>" >
<input placeholder="TANGGAL SELESAI CUTI" class="datepicker" size="16" type="text" name="tgl_selesai" id="tgl_selesai" value="<?php echo set_value('tgl_selesai'); ?>" >
</div>
</div>
<div class="form_row">
<label class="field_name">lama</label>
<div class="field">
<input type="text" name="lama" class="input-large" value="<?php echo set_value('lama'); ?>" placeholder="masukan lama cuti">
</div>
</div>
<div class="form_row">
<label class="field_name">Lampiran</label>
<div class="field">
<input type="file" name="userfile">
</div>
</div>
<div class="form_row">
<label class="field_name">Keterangan (MAKS 50 KARAKTER)</label>
<div class="field">
<textarea placeholder="KETERANGAN CUTI" id="ket" name="ket" class="span12" cols="40" rows="5" value="<?php echo set_value('ket'); ?>"></textarea>
</div>
</div>
<div class="form_row">
<div class="field">
<a onclick="return confirmdlg()" class="blue btn">Submit</a>
Cancel
</div>
</div>
</form>
I have change my view and model
in view
<form id="frmsave" name="frmsave" class="form-validate" enctype="multipart/form-data" >
and this my model
public function add() {
$npp = $this->session->userdata('NPP');
$id_jenis = $this->input->post('id_jenis');
$ket = $this->input->post('ket');
$lama = $this->input->post('lama');
$tgl_selesai= date('Y-m-d', strtotime($this->input->post('tgl_selesai')));
$tgl_mulai= date('Y-m-d', strtotime($this->input->post('tgl_mulai')));
$lampiran = $_FILES['userfile']['name'];
$data = array(
'npp'=> $npp,
'id_jenis'=> $id_jenis,
'tgl_pengajuan' => date('y-m-d'),
'ket' => $ket,
'status' => 'P',
'lampiran'=> $lampiran,
'lama'=> $lama,
'tgl_mulai'=> $tgl_mulai,
'tgl_selesai'=> $tgl_selesai);
and result can't insert to my database
The upload process must be done after the validation, and use $this->upload->display_errors() to see what's wrong :
$this->form_validation->run() === TRUE) {
$this->load->library('upload');
$this->upload->initialize($config);
if (!$this->upload->do_upload()){
$data['errors'] = $this->upload->display_errors(); // <-- HERE
$this->load->view('index', $data);
}
else{
$upload_data = $this->upload->data();
$this->load->model('Cutidiluar_Model');
$this->Cutidiluar_Model->add();
}