Commit fe1882e3 by Jansa Jose

upload pic changes

parent e0080626
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
if($custResp == '1'){ if($custResp == '1'){
$postData['user_type'] = 1;
$custResp = $this->Webservice_model->checkCustomerLogin($postData); $custResp = $this->Webservice_model->checkCustomerLogin($postData);
if(empty($custResp) || !isset($custResp['status']) || empty($custResp['status'])){ if(empty($custResp) || !isset($custResp['status']) || empty($custResp['status'])){
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
...@@ -235,22 +236,43 @@ ...@@ -235,22 +236,43 @@
//upload profilepic //upload profilepic
public function upload_profilePic(){ public function upload_profilePic(){
header('Content-type: application/json'); header('Content-type: application/json');
$postData = $_POST; //$postData = $_POST;
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Something went wrong.'); $respArr = array('status'=>'error','message'=>'Something went wrong.');
if(!isset($postData['user_id']) || empty($postData['user_id'])){ if(!isset($postData['user_id']) || empty($postData['user_id'])){
$respArr['message'] = 'User Id is Required'; $respArr['message'] = 'User Id is Required';
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
if(isset($_FILES) && !empty($_FILES) && isset($_FILES['user_profilepic']) && !empty($_FILES['user_profilepic'])){
$config = set_upload_service("assets/uploads/customer");
$this->load->library('upload'); // if(isset($_FILES) && !empty($_FILES) && isset($_FILES['user_profilepic']) && !empty($_FILES['user_profilepic'])){
$config['file_name'] = time()."_".$_FILES['user_profilepic']['name']; // $config = set_upload_service("assets/uploads/customer");
$this->upload->initialize($config); // $this->load->library('upload');
if($this->upload->do_upload('user_profilepic')){ // $config['file_name'] = time()."_".$_FILES['user_profilepic']['name'];
$upload_data = $this->upload->data(); // $this->upload->initialize($config);
$postData['profile_photo'] = $config['upload_path']."/".$upload_data['file_name']; // if($this->upload->do_upload('user_profilepic')){
} // $upload_data = $this->upload->data();
} // $postData['profile_photo'] = $config['upload_path']."/".$upload_data['file_name'];
// }
// }
$folderPath = "assets/uploads/customer/";
$image_parts = explode(";base64,", $postData['user_profilepic']);
$image_type_aux = explode("image/", $image_parts[0]);
$image_type = $image_type_aux[1];
$image_base64 = base64_decode($image_parts[1]);
$file = $folderPath . uniqid() . '.jpg';
file_put_contents($file, $image_base64);
$postData['profile_photo'] = $file;
$custResp = $this->Webservice_model->upload_profilePic($postData); $custResp = $this->Webservice_model->upload_profilePic($postData);
if($custResp == '1'){ if($custResp == '1'){
$respArr = array('status'=>'success','message'=>'Profile Pic Updated Successfully'); $respArr = array('status'=>'success','message'=>'Profile Pic Updated Successfully');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment