step 4 : perbaikan 10.9.9.8 upload lampiran
This commit is contained in:
@@ -2625,13 +2625,15 @@ class Re_px extends MY_Controller
|
||||
]);
|
||||
}
|
||||
|
||||
$filenameLab = $order_id . '-' . 'Lab' . '-' . date('Y') . '-' . $this->generateRandomString(5);
|
||||
$filenameLab = $order_id . '-' . 'Lab' . '-' . date('Y') . '-' . $this->generateRandomString(5) . "." . $extension_Lab;
|
||||
$_FILES['file']['name'] = $filenameLab;
|
||||
$_FILES['file']['type'] = $_FILES['fileLab']['type'][0];
|
||||
$_FILES['file']['tmp_name'] = $_FILES['fileLab']['tmp_name'][0];
|
||||
$_FILES['file']['error'] = $_FILES['fileLab']['error'][0];
|
||||
$_FILES['file']['size'] = $_FILES['fileLab']['size'][0];
|
||||
|
||||
|
||||
// allowed types di ubah ke * mime detection tidak jalan
|
||||
$config['allowed_types'] = '*';
|
||||
$config['file_name'] = $filenameLab;
|
||||
$this->upload->initialize($config);
|
||||
|
||||
@@ -2703,7 +2705,7 @@ class Re_px extends MY_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function upload_file_lampiran_by_order_id()
|
||||
public function upload_file_lampiran_by_order_id_v1()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
@@ -2923,6 +2925,234 @@ class Re_px extends MY_Controller
|
||||
// }
|
||||
}
|
||||
|
||||
public function upload_file_lampiran_by_order_id()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$inp = $this->sys_input;
|
||||
$order_id = $inp['orderid'];
|
||||
$data = [];
|
||||
|
||||
if ($order_id == "0" || $order_id == 0) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Tidak Ada Pemeriksaan",
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $status = "";
|
||||
|
||||
// Valid file extensions
|
||||
$valid_extensions = array("jpg", "jpeg", "png", "pdf");
|
||||
|
||||
// echo $orderid;
|
||||
|
||||
$date = date('Y');
|
||||
$target_dir_one_media = "/home/one/project/one/one-media/";
|
||||
$target_dir_one_attachment = "/home/one/project/one/one-media/one-attachment/";
|
||||
$target_dir = "/home/one/project/one/one-media/one-attachment/lampiran-result-entry-$date/";
|
||||
|
||||
// check folder sudah ada apa belum
|
||||
// if(!is_dir($target_dir_one_media)){
|
||||
// mkdir($target_dir_one_media, 0777, true);
|
||||
if (!is_dir($target_dir_one_attachment)) {
|
||||
mkdir($target_dir_one_attachment, 0777, true);
|
||||
}
|
||||
// }
|
||||
if (!is_dir($target_dir)) {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => "ERR : Folder Upload Di Server Belum Ada",
|
||||
// ]);
|
||||
// exit;
|
||||
mkdir($target_dir, 0777, true);
|
||||
}
|
||||
if (!is_dir($target_dir)) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "ERR : Folder Upload Di Server Belum Ada $target_dir",
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$config['upload_path'] = $target_dir;
|
||||
// if(!is_dir($config['upload_path'])) mkdir($target_dir, 0777, TRUE);
|
||||
$config['allowed_types'] = 'jpg|jpeg|png|pdf';
|
||||
$config['max_size'] = '10000';
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
// yang diupload hanya lab
|
||||
if (!empty($_FILES['fileLab']['name'])) {
|
||||
// $status = "lab";
|
||||
$resx_lab = $this->proses_upload_lab(
|
||||
$_FILES,
|
||||
$config,
|
||||
$valid_extensions,
|
||||
$order_id,
|
||||
$date,
|
||||
$userid,
|
||||
$target_dir
|
||||
);
|
||||
// print_r($resx_lab);
|
||||
if ($resx_lab['status'] == "OK") {
|
||||
$data['totalFiles'] = $resx_lab['data'];
|
||||
$result = array(
|
||||
"total" => count($data['totalFiles']),
|
||||
"records" => $data['totalFiles'],
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $resx_lab['message'],
|
||||
"error" => $resx_lab['error'],
|
||||
"path" => $resx_lab['path']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// jika di upload lab dan non lab
|
||||
// if (!empty($_FILES['fileNonLab']['name'])) {
|
||||
// // $status = "nonlab";
|
||||
// $resx = $this->proses_upload_non_lab(
|
||||
// $_FILES,
|
||||
// $config,
|
||||
// $valid_extensions,
|
||||
// $order_id,
|
||||
// $date,
|
||||
// $userid,
|
||||
// $target_dir
|
||||
// );
|
||||
|
||||
// // echo $resx['status'];
|
||||
|
||||
// if ($resx['status'] == "OK") {
|
||||
// // $data['totalFiles'] = $resx[0]['data'];
|
||||
// // $result = array(
|
||||
// // "total" => count($data['totalFiles']),
|
||||
// // "records" => $data['totalFiles'],
|
||||
// // );
|
||||
// // $this->sys_ok($result);
|
||||
|
||||
// if (empty($_FILES['fileLab']['name'])) {
|
||||
// $data['totalFiles'] = $resx['data'];
|
||||
// $result = array(
|
||||
// "total" => count($data['totalFiles']),
|
||||
// "records" => $data['totalFiles'],
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// } else {
|
||||
// // check lab dan upload
|
||||
// if (!empty($_FILES['fileLab']['name'])) {
|
||||
// $resx_lab = $this->proses_upload_lab(
|
||||
// $_FILES,
|
||||
// $config,
|
||||
// $valid_extensions,
|
||||
// $order_id,
|
||||
// $date,
|
||||
// $userid,
|
||||
// $target_dir
|
||||
// );
|
||||
// if ($resx_lab['status'] == "OK") {
|
||||
// $data['totalFiles'] = $resx_lab['data'];
|
||||
// $result = array(
|
||||
// "total" => count($data['totalFiles']),
|
||||
// "records" => $data['totalFiles'],
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// } else {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => $resx_lab['message'],
|
||||
// "error" => $resx_lab['error'],
|
||||
// "path" => $resx_lab['path']
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => $resx['message'],
|
||||
// "error" => $resx['error'],
|
||||
// "path" => $resx['path']
|
||||
// ]);
|
||||
// }
|
||||
// } else {
|
||||
// if (!empty($_FILES['fileLab']['name'])) {
|
||||
// // $status = "lab";
|
||||
// $resx_lab = $this->proses_upload_lab(
|
||||
// $_FILES,
|
||||
// $config,
|
||||
// $valid_extensions,
|
||||
// $order_id,
|
||||
// $date,
|
||||
// $userid,
|
||||
// $target_dir
|
||||
// );
|
||||
// if ($resx_lab['status'] == "OK") {
|
||||
// // $data['totalFiles'] = $resx_lab['data'];
|
||||
// // $result = array(
|
||||
// // "total" => count($data['totalFiles']),
|
||||
// // "records" => $data['totalFiles'],
|
||||
// // );
|
||||
// // $this->sys_ok($result);
|
||||
|
||||
// if (empty($_FILES['fileNonLab']['name'])) {
|
||||
// $data['totalFiles'] = $resx_lab['data'];
|
||||
// $result = array(
|
||||
// "total" => count($data['totalFiles']),
|
||||
// "records" => $data['totalFiles'],
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// } else {
|
||||
// // check non lab dan upload
|
||||
// if (!empty($_FILES['fileNonLab']['name'])) {
|
||||
// $resx = $this->proses_upload_non_lab(
|
||||
// $_FILES,
|
||||
// $config,
|
||||
// $valid_extensions,
|
||||
// $order_id,
|
||||
// $date,
|
||||
// $userid,
|
||||
// $target_dir
|
||||
// );
|
||||
|
||||
// if ($resx['status'] == "OK") {
|
||||
// $data['totalFiles'] = $resx['data'];
|
||||
// $result = array(
|
||||
// "total" => count($data['totalFiles']),
|
||||
// "records" => $data['totalFiles'],
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// } else {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => $resx['message'],
|
||||
// "error" => $resx['error'],
|
||||
// "path" => $resx['path']
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// echo json_encode([
|
||||
// "status" => "ERR",
|
||||
// "message" => $resx_lab['message'],
|
||||
// "error" => $resx_lab['error'],
|
||||
// "path" => $resx_lab['path']
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public function test_make_directory()
|
||||
{
|
||||
$date = date('Y');
|
||||
|
||||
Reference in New Issue
Block a user