Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index_post()
- {
- $foto = $_FILES['gambar']['name'];
- $email = $this->post('email');
- $password = $this->post('password');
- if ($foto == '') {
- $foto = 'blank_profile.png';
- } else {
- $config['upload_path'] = './assets/images/'; // lokasi penyimpanan gambar
- $config['allowed_types'] = 'jpg|png|jpeg'; // format gambar yang bisa di upload
- $this->load->library('upload', $config);
- if (!$this->upload->do_upload('foto')) {
- // jika foto gagal di inputkan
- echo "failed upload foto";
- } else {
- $foto = $this->upload->data('file_name');
- }
- }
- $data = [
- "email" => $email,
- "password" => $password,
- "gambar" => $foto
- ];
- if ($this->login->insert($data) > 0) {
- $this->response([
- 'status' => true,
- 'message' => 'data berhasil di tambahkan'
- ], 201);
- } else {
- $this->response([
- 'status' => false,
- 'message' => 'data gagal ditambahkan'
- ], 400);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement