ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/home2/selectio/www/y1jobportal.in/admin/api/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/home2/selectio/www/y1jobportal.in/admin/api/add_slider.php

<?php
include_once('config/config.php');
include_once('config/custom-functions.php');
include 'config/send-sms.php';
$fn = new custom_functions();
/* 
-------------------------------------------
APIs for Speedconnect
-------------------------------------------
2. add pickup address
3. Edit pickup address
4. delete pickup address
-------------------------------------------
*/



try{    
  
    

    if(isset($_FILES['slider_image']) && $_FILES["slider_image"]["name"]!=""){ 
                        $file_name = $_FILES['slider_image']['name'];
                        $tmp = explode('.', $file_name);
                        $extension = end($tmp);
                        $photo = rand(10,1000000000)."-image." . $extension;
                        $upload = move_uploaded_file($_FILES['slider_image']['tmp_name'], '../upload/slider/' . $photo);
                        $upload_photo = 'upload/slider/' . $photo;   
                }
                else{
                    $upload_photo='';
                }

   
    
    $uuid=$fn->gen_uuid();

        $statement = $pdo->prepare("INSERT INTO `tbl_slider`(`photo`, `status`)
                                    VALUES (?,?)");
    	$result = $statement->execute(array($upload_photo,1));
    	if($result){
		    $response['error']=false;
		    $response['message']="Slider Image added successfuly";
		}else{
		    $response['error']=true;
		    $response['message']='failed';
		}
}catch(Exception $e){
    $response['error']=true;
    $response['message']='something went wrong :'.$e;
    error_log($e);
}   
echo json_encode($response);




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

    $ids = $_POST['ids'];
    $status = $_POST['status'];
    
    if(isset($_FILES['slider_image']) && $_FILES["slider_image"]["name"]!=""){ 
            $file_name = $_FILES['slider_image']['name'];
            $tmp = explode('.', $file_name);
            $extension = end($tmp);
            $photo = rand(10,1000000000)."-image." . $extension;
            $upload = move_uploaded_file($_FILES['slider_image']['tmp_name'], '../upload/slider/' . $photo);
            $upload_photo = 'upload/slider/' . $photo;   
    }
    else{
        $upload_photo= $_POST['old_slider_image'];
    }


$statement = $pdo->prepare("UPDATE `tbl_slider` SET `photo`=?, `status`=? WHERE id=?");
$result=$statement->execute(array($upload_photo, $status, $ids));
 
             

 
    if($result){

                $return_arr['message']='State 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