codeigniter form with image upload - php

I have a field of my form (which is uploading personal picture). So the user selects image from pc and submit the form.
Controller:
function do_upload()
{
$config['upload_path'] = './images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100000';
$config['max_width'] = '10240';
$config['max_height'] = '7680';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($this->upload->data());
$datafoto = $this->upload->data();
$nm_file = time().$datafoto['orig_name'];
$this->load->model('mkegiatan');
$this->mkegiatan->update_foto($nm_file);
copy('images/'.$datafoto['orig_name'], 'images/'.$nm_file);
}
}
And contoller edit event like this:
function edit_kegiatan()
{
$id_kegiatan = $this->uri->segment(4);
//set validation properties
$this->form_validation->set_rules('tanggal_kegiatan', 'Tanggal', 'required');
$this->form_validation->set_rules('nama_kegiatan', 'Judul Berita', 'required');
$this->form_validation->set_rules('content', 'Content', 'required');
//run validation
// jika dia ingin update data atau form validation error
if ($this->form_validation->run() == FALSE) {
$data = $this->mkegiatan->get_by_id($id_kegiatan);
$this->load->model('mkegiatan');
$config['upload_path'] = './images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100000';
$config['max_width'] = '10240';
$config['max_height'] = '7680';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile')) //you forgot this
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
//print_r($this->upload->data());
$datafoto=$this->upload->data();
$nm_file = time().$datafoto['orig_name'];
$data = array(
'tanggal_kegiatan' => $this->input->post('tanggal_kegiatan'),
'nama_kegiatan' => $this->input->post('nama_kegiatan'),
'content' => $this->input->post('content'),
'image' => $nm_file
);
$this->mkegiatan->update_kegiatan($id_kegiatan,$data);
$this->session->set_flashdata('message', generateSuccessMessage('Data berhasil diupdate'));
redirect(site_url('admin/kegiatan'));
}
}
$this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
//var_dump($data);
//$tmp_data = array('id_kegiatan' => $id_kegiatan);
$this->data['contents'] = $this->load->view('admin/kegiatan/edit_kegiatan', $this->data, true);
$this->load->view('template/wrapper/admin/wrapper_ukm',$this->data);
}
View:
<?php echo form_open(current_url(),'name=form'); ?>
<div class="fours fields">
<div class="field">
<div class="ui vertical segment">
<div class="date field">
<label>Tanggal</label>
<div class="ui small icon input left">
<input type="text" id="datepicker" placeholder="xxxx-xx-xx" name="tanggal_kegiatan" value="<?php echo $tanggal_kegiatan;?>"><?php echo form_error('tanggal_kegiatan', '<div class="ui red pointing label">', '</div>'); ?>
<i class="calendar icon"></i>
</div>
</div>
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label>Nama Acara</label>
<div class="ui small left icon input">
<input type="text" placeholder="Nama Kegiatan" name="nama_kegiatan" value="<?php echo $nama_kegiatan;?>"><?php echo form_error('nama_kegiatan', '<div class="ui red pointing label">', '</div>'); ?>
<i class="text file outline icon"></i>
</div>
</div>
</div>
<div class="field">
<label>Isi Kegiatan</label>
<textarea placeholder="Text" name="content">
<?php echo $content;?>
</textarea><?php echo form_error('content', '<div class="ui red pointing label">', '</div>'); ?>
</div>
<input type="file" name="userfile" size="20">
<input class="ui small blue submit button" type="submit" value="Save">
</form>
Do I need to create two separate forms to accomplish this (one for the image upload and one for the text input)? Or is it possible to write a function in the controller that can validate and process both the upload and text input simultaneously?

try this
function tambah_kegiatan()
{
//set validation properties
$this->form_validation->set_rules('nama_kegiatan', 'Judul Berita', 'required');
if ($this->form_validation->run() == true)
{
$this->load->model('mkegiatan');
$config['upload_path'] = './images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100000';
$config['max_width'] = '10240';
$config['max_height'] = '7680';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile')) //you forgot this
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($this->upload->data());
$datafoto=$this->upload->data();
$nm_file = time().$datafoto['orig_name'];
$data = array(
'nama_kegiatan' => $this->input->post('nama_kegiatan'),
'image' => $nm_file
);
$this->mkegiatan->insert_kegiatan($data);
$this->session->set_flashdata('message', generateSuccessMessage('Data berhasil ditambah'));
redirect(site_url('admin/kegiatan'));
}
}
$this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
$this->data['contents'] = $this->load->view('admin/kegiatan/tambah_kegiatan', '', true);
$this->load->view('template/wrapper/admin/wrapper_ukm',$this->data);
}
and your image folder having all permissions
function edit_kegiatan($id_kegiatan='')
{
//set validation properties
$this->form_validation->set_rules('tanggal_kegiatan', 'Tanggal', 'required');
$this->form_validation->set_rules('nama_kegiatan', 'Judul Berita', 'required');
$this->form_validation->set_rules('content', 'Content', 'required');
//run validation
// jika dia ingin update data atau form validation error
if ($this->form_validation->run() == FALSE) {
$data = $this->mkegiatan->get_by_id($id_kegiatan);
$this->load->model('mkegiatan');
$config['upload_path'] = './images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100000';
$config['max_width'] = '10240';
$config['max_height'] = '7680';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile')) //you forgot this
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
//print_r($this->upload->data());
$datafoto=$this->upload->data();
$nm_file = time().$datafoto['orig_name'];
$data = array(
'tanggal_kegiatan' => $this->input->post('tanggal_kegiatan'),
'nama_kegiatan' => $this->input->post('nama_kegiatan'),
'content' => $this->input->post('content'),
'image' => $nm_file
);
$this->mkegiatan->update_kegiatan($id_kegiatan,$data);
$this->session->set_flashdata('message', generateSuccessMessage('Data berhasil diupdate'));
redirect(site_url('admin/kegiatan'));
}
}
$this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
//var_dump($data);
//$tmp_data = array('id_kegiatan' => $id_kegiatan);
$this->data['contents'] = $this->load->view('admin/kegiatan/edit_kegiatan', $this->data, true);
$this->load->view('template/wrapper/admin/wrapper_ukm',$this->data);
}

Related

How to upload files in two different folders using CodeIgniter3?

How to upload images and videos in two different folders using CodeIgniter 3?
I have done only images. Please guide me through videos. I want to upload image and videos in two different folders.
My Controller, Model and View
class Blog extends CI_Contrller{
public function create_blog(){
// Check Login
if(!$this->session->userdata('logged_in')){
redirect('blogs/login');
}
$data['title'] = 'Create Blog';
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('content', 'Content', 'required');
if($this->form_validation->run() === FALSE){
$this->load->view('templates/header');
$this->load->view('blog/create_blog', $data);
$this->load->view('templates/footer');
} else {
// Upload Image
$path = './assets/uploads/blogs/images';
$config['upload_path'] = $path;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 15000;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if(!$this->upload->do_upload()){
$this->session->set_flashdata('file_error', $this->upload->display_errors());
$post_image = 'noimage.jpg';
redirect('blog/create_blog');
}else{
$data = array('upload_data' => $this->upload->data());
$post_image = $_FILES['userfile']['name'];
}
$this->M_blog->create_blog($post_image);
redirect('blog/view');
}
}
}
Model
// Model Begins here
public function create_blog($post_image){
$slug = url_title($this->input->post('title'));
$data = array(
'title' => $this->input->post('title'),
'slug' => $slug,
'content' => $this->input->post('content'),
'image' => $post_image
);
return $this->db->insert('events', $data);
}
View
// View begins here
<div class="container"><br>
<h2><?= $title ?></h2>
<?php echo form_open_multipart('blog/create_blog'); ?>
<?php echo validation_errors(); ?>
<?php echo $this->session->flashdata('file_error'); ?>
<div class="form-group">
<label>Title</label>
<input type="text" class="form-control" name="title"
placeholder="Add Title">
</div>
<div class="form-group">
<label>Body</label>
<textarea class="form-control" id="editor1" name="content"
placeholder="Add Body"></textarea>
</div>
<div class="form-group">
<label>Upload Image</label>
<input type="file" name="userfile" id="userfile" size="20" />
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
Try this
class Blog extends CI_Contrller{
function create_blog() {
// Check Login
if (!$this->session->userdata('logged_in')) {
redirect('blogs/login');
}
$data['title'] = 'Create Blog';
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('content', 'Content', 'required');
if ($this->form_validation->run() === FALSE) {
$this->load->view('templates/header');
$this->load->view('blog/create_blog', $data);
$this->load->view('templates/footer');
} else {
// Upload Image
$ext = pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION);
$ext = strtolower($ext);
$image_ext_arr = array('gif', 'jpg', 'png', 'jpeg');
if (in_array($ext, $image_ext_arr)) {
$path = FCPATH.'assets/uploads/blogs/images';
$allowed_types = 'gif|jpg|png';
} else {
$path = FCPATH.'assets/uploads/blogs/video';
$allowed_types = 'mp4|mp3';
}
$config['upload_path'] = $path;
$config['allowed_types'] = $allowed_types;
$config['max_size'] = 15000;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if (!$this->upload->do_upload()) {
$this->session->set_flashdata('file_error', $this->upload->display_errors());
$post_image = 'noimage.jpg';
redirect('blog/create_blog');
} else {
$data = array('upload_data' => $this->upload->data());
$post_image = $_FILES['userfile']['name'];
}
$this->M_blog->create_blog($post_image);
redirect('blog/view');
}
}
}
Added few line :
$ext = pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION); //to find whether is image or video
$ext = strtolower($ext);// some time extension in upper later so converted into small letters
$image_ext_arr = array('gif', 'jpg', 'png', 'jpeg'); //give here all extension of image that you want to upload
if (in_array($ext, $image_ext_arr)) { //if matches means is image
$path = FCPATH.'assets/uploads/blogs/images';
$allowed_types = 'gif|jpg|png';
} else { //else video
$path = FCPATH.'assets/uploads/blogs/video';
$allowed_types = 'mp4|mp3';
}
Note : Better to give absolute path instead of relative path to upload so
$path = FCPATH.'assets/uploads/blogs/video';

update image on codeigniter

I'm stuck from make a update image from codeigniter, i want replace image when i update it but, the code its doesn't work.
here is my code :
this is Controller :
public function updatefoto(){
$this->load->model('model_users');
$this->model_users->updatefoto();
}
This is The Model
public function updatefoto($userId){
if($this->input->post('submit')){
$config['upload_path'] = "./uploads/images/";
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '2000';
$config['max_width'] = '2000';
$config['max_height'] = '2000';
$config['file_name'] = 'gambar-'.trim(str_replace(" ","",date('dmYHis')));
$this->load->library('upload', $config);
if (!$this->upload->do_upload("gambar")) {
$error = array('error' => $this->upload->display_errors('<div class="alert alert-danger">×','</div>'));
$this->load->view('view_ubah_data-profile', $error);
}else{
$nama=$this->upload->data('file_name');
$this->db->where('id', $userId);
$this->db->update('foto',array('nama_foto'=>$nama));
redirect('view_ubah_data-profile','refresh');
}
}
}
and the last is view
<div class="col-md-4 col-sm-6 col-xs-12">
<form action="users/updatefoto" method="post" id="updateUserImage">
<div class="text-center">
<img src="<?php echo base_url();?>uploads/images/<?php echo $userData['nama_foto'] ?>" cclass="img-thumbnail" alt="avatar">
<h6>Upload a different photo...</h6>
<input type="file" class="text-center center-block well well-sm" name="gambar" id="files" accept="image/*" required>
<button type="submit" value="Upload" name="submit" class="btn btn-primary">
<i class="fa fa-upload" aria-hidden="true"></i>upload
</button>
</div>
</form>
</div>
Thanks I appreciate any help :)
Here is how I do it.
Edit- Class Construct
class Team extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->load->helper(array('form', 'url'));
$this->load->model('team_model');
}
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile1'))
{
$data['errors'] = array('error' => $this->upload->display_errors());
$data['client_Id']=$this->team_model->getUserId($email);
$data['pic']=$this->team_model->getImage($data['client_Id']['id']);
// Here I load my Views
}
else
{
$upload_data = $this->upload->data();
$file_name=$upload_data['file_name'];
$email=$this->session->userdata['email'];
$data['client_Id']=$this->team_model->getUserId($email);
$data['pic']=$this->team_model->getImage($data['client_Id']['id']);
// If there is no image insert one other wise update
if($data['pic']['image']!=''){
$this->team_model->updateEmployeeImage($data['pic']['id'],$file_name);
$data['success']='Congratulations! Image Updated Successfully';
}else{
$this->team_model->InsertEmployeeImage($data['client_Id']['id'],$file_name);
$data = array('upload_data' => $this->upload->data());
$data['success']='Congratulations! Image Uploaded Successfully';
}
$file_name=$upload_data['file_name'];
$email=$this->session->userdata['email'];
$data['client_Id']=$this->team_model->getUserId($email);
$data['pic']=$this->team_model->getImage($data['client_Id']['id']);
// Here I load my Views
}
}
}
Edit- Model Functions
public function InsertEmployeeImage($id,$image){
$Image=array(
'id' => '',
'team_id' => $id,
'image' => $image
);
$this->db->insert('teams_image',$Image);
return ;
}
public function updateEmployeeImage($id,$img){
$this->deleteOldImage($id);
$pic=array(
'image' => $img
);
$this->db->WHERE('id',$id)->update('teams_image',$pic);
}

Image not uploading Codeigniter

My image upload gives following error
Array ( [error] =>
You did not select a file to upload.
)
Here is the html
<div class="form-group">
<label class="col-sm-3 control-label">Product Image</label>
<div class="col-sm-9">
<input type="file" name="item_image" />
</div>
</div>
Here is the controller
$config['upload_path'] = './images/item_images';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$error = '';
$udata = '';
$this->load->library('upload');
$this->upload->initialize($config);
if (!$this->upload->do_upload('item_image')) {
$error = array('error' => $this->upload->display_errors());
print_r($error);
} else {
$udata = array('upload_data' => $this->upload->data());
print_r($udata);
$item_data['image_url'] = "images/item_images/" . $udata['upload_data']['file_name'];
}
I can't fix my error

image upload in codeigniter giving error

I am upload an image in one my form but its always giving me an error like
"A PHP Error was encountered Severity: Notice Message:
Undefined index: vimage Filename: controllers/vouchers.php Line
Number: 42"
My View File code :
<?php echo form_open_multipart(site_url("promotions/add_item/"), array("class" => "form-horizontal","id"=>"addItem")) ?>
<div class="form-group">
<label class="col-sm-3 control-label">Show on</label>
<div class="col-sm-3">
Artist Directory : <input type="checkbox" name="artist_dir" value='1'>
</div>
<div class="col-sm-3">
Highlight : <input type="checkbox" name="highlight" value='1'>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Title</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="title" id="title" placeholder="Title">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Image</label>
<div class="col-sm-9">
<input type="file" name="pro_image">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Description</label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" name="description" placeholder="Description"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-success" name="submit" id="submit">Submit</button>
</div>
</div>
<?php echo form_close() ?>
My Controller Code :
<pre>
public function add_item(){
$this->load->library('upload');
$this->form_validation->set_rules('title','Title','required');
$this->form_validation->set_rules('description','Description','required');
print_r($_FILES['pro_image']);
if ($_FILES['pro_image']['size'] > 0) {
$this->upload->initialize(array(
"upload_path" => './uploads/',
"overwrite" => FALSE,
"encrypt_name" => TRUE,
"remove_spaces" => TRUE,
"allowed_types" => "gif|jpg|png|jpeg",
));
if (!$this->upload->do_upload('vimage')) {
$this->upload->display_errors();
}
$data = $this->upload->data();
echo 'img : '.$img = $data['file_name'];
}
exit;
if($this->form_validation->run()==FALSE){
echo '<div class="alert alert-dismissable alert-danger"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><small>'. validation_errors().'</small></div>';
}
else {
$title = $this->input->post('title');
$description = $this->input->post('description');
$artist_dir = $this->input->post('artist_dir');
$highlight = $this->input->post('highlight');
$this->promotions_model->add_item($title, $description,$artist_dir,$highlight);
}
}
</pre>
please let me know what i am doing wrong here
Try this
if ($_FILES['vimage']['size'] > 0) {
$this->load->library('upload');
$this->upload->initialize($this->set_upload_options());
$this->upload->do_upload();
$fileName = $_FILES['vimage']['name'];
private function set_upload_options()
{
// upload an image options
$config = array();
$config['upload_path'] = './upload/'; //give the path to upload the image in folder
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '0';
$config['overwrite'] = FALSE;
return $config;
}
For more read this Link
Try this
if (!empty($_FILES['vimage']))
{
$config['upload_path'] = './uploads/';
//$config['max_size'] = '102400';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['overwrite'] = FALSE;
$config['remove_spaces'] = TRUE;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload('vimage'))
{
$this->session->set_flashdata('error', $this->upload->display_errors());
//redirect('controller/method');
}
else
{
$this->session->set_flashdata('success', 'Image Has been Uploaded');
//redirect('controller/method');
$img = $data['file_name'];
}
}
Please check first,
print_r(_FILES);
If you get files array then you can use below code for uploading image.
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
// You can give Image formats if you want to upload any video file.
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' = $this->upload->display_errors());
// uploading failed. $error will holds the errors.
}
else
{
$data = array('upload_data' => $this->upload->data());
// uploading successfull, now do your further actions
}
}
I have added your code in my system it's working for fine for me.
public function add(){
$this->load->library('upload');
$this->load->helper('form');
$this->load->helper('url');
print_r($_FILES);die;
$this->form_validation->set_rules('title','Title','required');
$this->form_validation->set_rules('description','Description','required');
if ($_FILES['pro_image']['size'] > 0) {
$this->upload->initialize(array(
"upload_path" => './uploads/',
"overwrite" => FALSE,
"encrypt_name" => TRUE,
"remove_spaces" => TRUE,
"allowed_types" => "gif|jpg|png|jpeg",
));
if (!$this->upload->do_upload('vimage')) {
$this->upload->display_errors();
}
$data = $this->upload->data();
echo 'img : '.$img = $data['file_name'];
}
exit;
if($this->form_validation->run()==FALSE){
echo '<div class="alert alert-dismissable alert-danger"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><small>'. validation_errors().'</small></div>';
}
else {
$title = $this->input->post('title');
$description = $this->input->post('description');
$artist_dir = $this->input->post('artist_dir');
$highlight = $this->input->post('highlight');
$this->promotions_model->add_item($title, $description,$artist_dir,$highlight);
}
}

CodeIgniter Upload Class Allowed File Types

I'm using Codeigniter Upload Class but I have a problem with allowed file types. I need to allow only pdf files to upload but any kind of file can be upload. Here is my code;
model (muser.php);
function cv_ekle()
{
$config['upload_path'] = 'uploads/cv';
$config['allowed_types'] = 'pdf';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$this->load->library('upload', $config);
$this->upload->do_upload();
$data = $this->upload->data();
$this->load->library('upload', $config);
$upload_data = $this->upload->data(); //Returns array of containing all of the data related to the file you uploaded.
$file_name = $upload_data['file_name'];
$data = array
(
'userid' => $this->session->userdata('id'),
'kullanici' => $this->session->userdata('isim'),
'kategori' => $this->input->post('kategori'),
'tarih' => time(),
'dosya' => $file_name
);
if($this->db->insert('cv', $data))
{
return true;
}
else
{
return false;
}
}
controller (cv.php);
function cv_ekle()
{
if($this->muser->cv_ekle())
{
$this->session->set_flashdata('ok', 'CV başarıyla gönderildi!');
redirect('cv');
}
else
{
$this->session->set_flashdata('hata', 'Sadece PDF, Excel ya da Word formatında yükleme yapabilirsiniz!');
redirect('cv');
}
}
view (cv.php);
<form method="post" action="<?php echo site_url('cv/cv_ekle'); ?>" class="login" enctype="multipart/form-data">
<div class="controls">
<label for="email">Dosya: <span class="text-error">*</span></label>
<input type="file" id="pass" class="input-block-level" name="userfile" >
</div>
<div class="controls">
<label for="email">Kategori: <span class="text-error">*</span></label>
<select class="input-block-level" name="kategori">
<?php foreach($kategoriler as $kat) { ?>
<option value="<?php echo $kat['isim']; ?>"><?php echo $kat['isim']; ?></option>
<?php } ?>
</select>
</div>
<div class="controls">
<button type="submit" class="btn btn-primary">CV Yükle</button>
</div>
</form>
Thanks in advance!
function cv_ekle()
{
$config['upload_path'] = 'uploads/cv';
$config['allowed_types'] = 'pdf';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$this->load->library('upload', $config);
$this->upload->do_upload();
$upload_data = $this->upload->data(); //Returns array of containing all of the data related to the file you uploaded.
$file_name = $upload_data['file_name'];
$data = array
(
'userid' => $this->session->userdata('id'),
'kullanici' => $this->session->userdata('isim'),
'kategori' => $this->input->post('kategori'),
'tarih' => time(),
'dosya' => $file_name
);
if($this->db->insert('cv', $data))
{
return true;
}
else
{
return false;
}
}

Categories