ok

Mini Shell

Direktori : /proc/thread-self/root/home2/selectio/public_html/y1jobportal.in/admin/apis/
Upload File :
Current File : //proc/thread-self/root/home2/selectio/public_html/y1jobportal.in/admin/apis/category.php

<?php
include "../api/config/config.php";


if(isset($_POST['type']) && $_POST['type']=='add_category'){
     try{


$date = date('Y-m-d', time());

if(isset($_FILES['image']) && $_FILES['image']['name']!="")
        {
            $file_name_1 = $_FILES['image']['name'];
            $tmp_1 = explode('.', $file_name_1);
            $extension_1 = end($tmp_1);
            $image_1 = rand(10,1000000000)."-".$date."-image." . $extension_1;
            $upload_1 = move_uploaded_file($_FILES['image']['tmp_name'], '../upload/category/' . $image_1);
            $category_proof = 'upload/category/' . $image_1;  
        }
        else
        {
            $category_proof = '';
        }


$statement = $pdo->prepare("INSERT INTO `category`(`name`, `image` ) VALUES (?,?)");
$result=$statement->execute(array($_POST['name'],$category_proof));
 
             

 
    if($result){

                $return_arr['message']='Materials Details Addded Successfully...';
                $return_arr['status']=200;
           } 
           else{
                $return_arr['message']='Something Went Wrong..';
                $return_arr['status']=400;
            }
            
            
             
}catch(PDOException $e){
        $return_arr['message']="$e";
        error_log("Query Error: ".$e);
        $return_arr['status']=500;
        $pdo->rollBack();
     }   
    echo json_encode($return_arr);
}


if(isset($_POST['type']) && $_POST['type']=='update_category'){
     try{



$date = date('Y-m-d', time());

if(isset($_FILES['image']) && $_FILES['image']['name']!="")
        {
          
            
            unlink($_POST['old_image']);
            $file_name_1 = $_FILES['image']['name'];
            $tmp_1 = explode('.', $file_name_1);
            $extension_1 = end($tmp_1);
            $image_1 = rand(10,1000000000)."-".$date."-image." . $extension_1;
            $upload_1 = move_uploaded_file($_FILES['image']['tmp_name'], '../upload/category/' . $image_1);
            $category_proof = 'upload/category/' . $image_1;  
        }
        else
        {
            $category_proof = $_POST['old_image'];
        }

$statement = $pdo->prepare("UPDATE category SET name = ?,image =? , status =? WHERE  id =? ");
$result=$statement->execute(array($_POST['name'],$category_proof,$_POST['status'],$_POST['ids']));

    if($result){

                $return_arr['message']='Category 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";
        error_log("Query Error: ".$e);
        $return_arr['status']=500;
        $pdo->rollBack();
     }   
    echo json_encode($return_arr);
}

?>

Zerion Mini Shell 1.0