Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- location: ajax/
- */
- include "../configs/base.php";
- include_once "../functions/_main.php";
- if(!isset($folderUpload)){
- $folderUpload = _SITEDIR_ . "/uploads/";
- if (!is_dir($folderUpload)) {
- mkdir($folderUpload);
- }
- }
- $res = [];
- $res["error"] = 1;
- if (isset($_POST["params"])) {
- //$json=openssl_decrypt( $_POST['params'] ,"AES-128-ECB", $password);
- $json = decryptData($_POST["params"]);
- $ar = json_decode($json ?? "");
- $res["param"] = $ar;
- $res["message"] = "upload telah success";
- $res["html"] = " ";
- $res["debug"] = [$_FILES, $_POST];
- $result = 1;
- //folder
- $res["debug"][] = "folder:" . $folderUpload;
- $folderTarget = $ar->folder ?? "example";
- $tanggalData = $ar->date ?? "2024-12-12";
- $num = $ar->num ?? "100";
- //filename
- $aFile = explode(".", $_FILES["file"]["name"] ?? "nofile.tmp");
- $ext = $aFile[count($aFile) - 1];
- $filename = $ar->filename ?? "test";
- $sourceFile = $_FILES["file"]["tmp_name"];
- if ($result == 1) {
- $targetFile = uploadAttachment(
- $sourceFile,
- $folderTarget,
- $filename,
- $ext,
- $tanggalData
- );
- $imgOnSite =
- "http://localhost:2082/" . str_replace(__DIR__, "", $targetFile);
- $time = round(microtime(1) * 1000);
- $res["html"] .= viewAttachment(
- $folderTarget,
- $filename,
- $tanggalData,
- $num
- );
- $res["error"] = 0;
- }
- //unset( $res['debug'] );
- }
- //$res['error']=1;$res['message']='extension tidak sesuai';
- echo json_encode($res);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement