-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdateTukangAvatar.php
More file actions
37 lines (30 loc) · 874 Bytes
/
updateTukangAvatar.php
File metadata and controls
37 lines (30 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
include_once('koneksi.php');
if (!empty($_POST['id'])) {
$id = $_POST['id'];
if (empty($_FILES['avatar'])) {
set_response(false, "Foto harus diisi");
} else {
$avatar = $_FILES['avatar']['name'];
$file = $_FILES['avatar']['tmp_name'];
$dir = "avatar/";
move_uploaded_file($file, $dir . $avatar);
$query = "UPDATE tukang set avatar = '$avatar' WHERE id = '$id'";
$update = pg_query($connect, $query);
if ($update) {
set_response(true, "Success update tukang");
} else {
set_response(false, "Failed update tukang");
}
}
} else {
set_response(false, "harus diisi");
}
function set_response($isSuccess, $message)
{
$result = array(
'isSuccess' => $isSuccess,
'message' => $message
);
echo json_encode($result);
}