function changeProfilePic($userId, $path) { $res = conn()->query("UPDATE users SET profile_pic='{$path}'\n WHERE id='{$userId}'"); if ($res) { addPostPic($userId, 'I have just changed my profile picture', $path, 1); // $res = conn()->query("INSERT INTO posts (user_id, caption, image_path, is_private) // VALUES ('$userId', 'I have just changed my profile picture', '$path', b'1')"); return true; } else { return false; } }
public function uploadPostPic($caption = '', $isPrivate = 1) { $response['signed'] = false; $response['succeeded'] = false; if (isset($_SESSION["user_id"]) && strlen(trim($_SESSION["user_id"])) > 0) { $path = 'assets/uploaded_images/' . time() . '_' . $_FILES['file']['name']; move_uploaded_file($_FILES['file']['tmp_name'], $path); $response['succeeded'] = addPostPic($_SESSION["user_id"], $caption, $path, $isPrivate); $response['signed'] = true; } echo json_encode($response); }