Commit fe1882e3 by Jansa Jose

upload pic changes

parent e0080626
......@@ -86,6 +86,7 @@
echo json_encode($respArr);exit;
}
if($custResp == '1'){
$postData['user_type'] = 1;
$custResp = $this->Webservice_model->checkCustomerLogin($postData);
if(empty($custResp) || !isset($custResp['status']) || empty($custResp['status'])){
echo json_encode($respArr);exit;
......@@ -235,22 +236,43 @@
//upload profilepic
public function upload_profilePic(){
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.');
if(!isset($postData['user_id']) || empty($postData['user_id'])){
$respArr['message'] = 'User Id is Required';
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');
$config['file_name'] = time()."_".$_FILES['user_profilepic']['name'];
$this->upload->initialize($config);
if($this->upload->do_upload('user_profilepic')){
$upload_data = $this->upload->data();
$postData['profile_photo'] = $config['upload_path']."/".$upload_data['file_name'];
}
}
// if(isset($_FILES) && !empty($_FILES) && isset($_FILES['user_profilepic']) && !empty($_FILES['user_profilepic'])){
// $config = set_upload_service("assets/uploads/customer");
// $this->load->library('upload');
// $config['file_name'] = time()."_".$_FILES['user_profilepic']['name'];
// $this->upload->initialize($config);
// 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);
if($custResp == '1'){
$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