Initial import
This commit is contained in:
87
application/controllers/tools/Imagetofolder.php
Normal file
87
application/controllers/tools/Imagetofolder.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
class Imagetofolder extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
|
||||
public function savedata()
|
||||
{
|
||||
$filename = $_FILES['filephoto']['name'];
|
||||
$path = '/home/one/project/one/one-media/one-photo/patient/'.date("Y").'/';
|
||||
if (!file_exists($path)) {
|
||||
if (! mkdir($path)) {
|
||||
$this->sys_error("Gagal membuat folder $path");
|
||||
}
|
||||
}
|
||||
$check = is_uploaded_file($_FILES["filephoto"]["tmp_name"]);
|
||||
if ($check) {
|
||||
if (move_uploaded_file($_FILES["filephoto"]["tmp_name"], $path . $filename)) {
|
||||
$cmd = "tar -xf $path$filename -C /home/one/project/one/one-media/one-photo/patient/".date('Y');
|
||||
// echo $cmd;
|
||||
exec($cmd);
|
||||
unlink($path.$filename);
|
||||
|
||||
$this->sys_ok(array("status" => "OK", "messge" => "file $filename uploaded"));
|
||||
} else {
|
||||
$this->sys_error("Gagal upload file $filename");
|
||||
}
|
||||
}
|
||||
}
|
||||
public function savedata_old()
|
||||
{
|
||||
//print_r($_FILES['file']);
|
||||
$filename = $_FILES['filephoto']['name'];
|
||||
|
||||
$path = '/home/one/project/one/one-media/one-photo/patient/'.date("Y").'/';
|
||||
if (!file_exists($path)) {
|
||||
mkdir($path);
|
||||
}
|
||||
//echo $path.$filename;
|
||||
//print_r(file_exists($path.$filename));
|
||||
unlink($path.$filename);
|
||||
if (!file_exists($path.$filename)) {
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = '*';
|
||||
$config['max_size'] = 20000;
|
||||
$config['max_width'] = 1024;
|
||||
$config['max_height'] = 768;
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if (! $this->upload->do_upload('filephoto')) {
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
$this->sys_error($this->upload->display_errors());
|
||||
exit;
|
||||
} else {
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
$cmd = "tar -xf $path$filename -C /home/one/project/one/one-media/one-photo/patient/".date('Y');
|
||||
//echo $cmd;
|
||||
exec($cmd);
|
||||
unlink($path.$filename);
|
||||
$this->sys_ok(array("status" => "OK", "messge" => "file $filename uploaded"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function uncompress($srcName, $dstName)
|
||||
{
|
||||
$sfp = gzopen($srcName, "rb");
|
||||
$fp = fopen($dstName, "w");
|
||||
|
||||
while (!gzeof($sfp)) {
|
||||
$string = gzread($sfp, 10000);
|
||||
fwrite($fp, $string, strlen($string));
|
||||
}
|
||||
gzclose($sfp);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user