ok
Direktori : /home2/selectio/www/caliberembedded.com/admin/add-api/ |
Current File : /home2/selectio/www/caliberembedded.com/admin/add-api/api-faculty-add.php |
<?php include "../config/config.php"; if(isset($_POST['type']) && $_POST['type']=='add_faculty'){ try{ $name = $_POST['name']; $designation = $_POST['designation']; $date = date('Y-m-d h:i:s', time()); if(isset($_FILES['photo']) && $_FILES["photo"]["name"]!=""){ $extension = end(explode(".", $_FILES["photo"]["name"])); $image = rand(10,1000000000)."-image." . $extension; $upload = move_uploaded_file($_FILES['photo']['tmp_name'], 'images/faculty/' . $image); $upload_image = 'images/faculty/' . $image; } else{ $upload_image=''; } $statement = $pdo->prepare("INSERT INTO `tbl_faculty`(`image`,`name`,`designation`,status`) VALUES (?,?,?,?)"); $result=$statement->execute(array($upload_image,$name,$designation,1)); if($result){ $return_arr['message']='Break Details Updated Successfully...'; $return_arr['status']=200; } else{ $return_arr['message']='Something Went Wrong..'; $return_arr['status']=400; } }catch(PDOException $e){ $return_arr['message']="$e"; $return_arr['status']=500; } echo json_encode($return_arr); } ?>