whoami7 - Manager
:
/
proc
/
thread-self
/
root
/
home
/
papecmvm
/
public_html
/
application
/
controllers
/
admin
/
Upload File:
files >> //proc/thread-self/root/home/papecmvm/public_html/application/controllers/admin/Mediamanagement.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ob_start(); error_reporting(0); class Mediamanagement extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('alldata','model'); } public function index() { $data['view']=$this->model->getDatamodel('tblmedia'); $this->load->view("media/media_view",$data); } public function add() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = '*'; $this->upload->initialize($config); $count = count($_FILES['mediafile']['size']); //echo $count; die; //foreach ($_FILES as $key => $value) { for ($s = 0; $s <= $count - 1; $s++) { $path_parts = pathinfo($_FILES['mediafile']['name'][$s]); $extension = $path_parts['extension']; //echo $extension; die; if ($extension != 'jpg' && $extension != 'png' && $extension != 'jpeg' && $extension != 'JPG' && $extension != 'pdf' && $extension != 'gif' && $extension != 'doc' && $extension != 'xlsx' && $extension != 'ppt') { //error $this->session->set_flashdata('msg', '<div class="alert alert-dismissible" role="alert" style="color: #a94442;background-color: #f2dede;border-color: #ebccd1;"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Error : </strong> Something went wrong...!</div>'); redirect('admin/mediamanagement', 'refresh'); } else { $_FILES['userfile']['name'] = $_FILES['mediafile']['name'][$s]; $_FILES['userfile']['type'] = $_FILES['mediafile']['type'][$s]; $_FILES['userfile']['tmp_name'] = $_FILES['mediafile']['tmp_name'][$s]; $_FILES['userfile']['error'] = $_FILES['mediafile']['error'][$s]; $_FILES['userfile']['size'] = $_FILES['mediafile']['size'][$s]; $this->load->library('upload', $config); $this->upload->do_upload(); $data = $this->upload->data(); $filename = 'uploads/' . $data['file_name']; $insertdata = array('file_name' => $data['file_name'], 'file_path' => $filename, 'filetype' => strtolower($data['file_ext'])); $this->model->insertData('tblmedia', $insertdata); } } redirect('admin/mediamanagement', 'refresh'); //} } public function add_old() { echo "<pre>"; $config['upload_path'] = './uploads/'; $config['allowed_types'] = '*'; $this->upload->initialize($config); $count = count($_FILES['mediafile']['size']); foreach($_FILES as $key=>$value) for($s=0; $s<=$count-1; $s++) { $path_parts = pathinfo($value['name'][$s]); $extension = $path_parts['extension']; //echo $extension; die; if($extension != 'jpg' && $extension != 'png' && $extension != 'jpeg' && $extension != 'pdf' && $extension != 'gif' && $extension != 'doc' && $extension != 'xlsx' && $extension != 'ppt'){ //error $this->session->set_flashdata('msg', '<div class="alert alert-dismissible" role="alert" style="color: #a94442;background-color: #f2dede;border-color: #ebccd1;"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>Error : </strong> Something went wrong...!</div>'); redirect('admin/mediamanagement','refresh'); }else{ $_FILES['userfile']['name']=$value['name'][$s]; $_FILES['userfile']['type'] = $value['type'][$s]; $_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s]; $_FILES['userfile']['error'] = $value['error'][$s]; $_FILES['userfile']['size'] = $value['size'][$s]; $this->load->library('upload', $config); $this->upload->do_upload(); $data = $this->upload->data(); $filename ='uploads/'.$data['file_name']; $insertdata=array('file_name' =>$data['file_name'] , 'file_path'=>$filename,'filetype'=>strtolower($data['file_ext'])); $this->model->insertData('tblmedia',$insertdata); } redirect('admin/mediamanagement','refresh'); } } public function deleteimageselected() { $ids=explode('&',$this->input->post('ck')); for ($i=0; $i < count($ids); $i++) { $id=explode('=',$ids[$i]); $where=array('tblmedia_id'=>$id[1]); $getbanner=$this->model->DetailData('tblmedia',$where); unlink($getbanner[0]['file_path']); $this->model->DeleteData('tblmedia',$where); } /* $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> File Data successfully Delete. </div>'); */ redirect('admin/mediamanagement'); } public function openmodel($id) { $where=array('tblmedia_id'=>$id); $data['view']=$this->model->DetailData('tblmedia',$where); $this->load->view("media/model_view",$data); } public function update(){ $where= array('tblmedia_id' => $this->input->post('id')); $insertdata=array('main_text' =>$this->input->post('main'), 'sub_text'=>$this->input->post('sub')); $this->model->UpdateData('tblmedia',$insertdata,$where); redirect('admin/mediamanagement'); } }
Copyright ©2021 || Defacer Indonesia