Created
March 28, 2016 16:30
-
-
Save edomaru/b27605aad57ca3c2f0d3 to your computer and use it in GitHub Desktop.
store other post when uplaod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class Site extends CI_Controller { | |
public function upload() | |
{ | |
if ( ! empty($_FILES)) | |
{ | |
$config['upload_path'] = "./assets/uploads"; | |
$config['allowed_types'] = 'gif|jpg|png|mp4|ogv'; | |
$this->load->library('upload', $config); | |
if (! $this->upload->do_upload("file")) { | |
echo "File cannot be uploaded"; | |
} | |
} | |
// here example to store other post data to database | |
if (count($_POST)) { | |
$upload_data = $this->upload->data(); | |
$this->db->insert('table_name', array( | |
'title' => $_POST['title'], | |
'description' => $_POST['description'], | |
'image' => $upload_data['file_name'] | |
)); | |
} | |
$this->listFiles(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment