MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/www/imenso.co/demo/claapp/config/function.php
<?php
function uploadfile($store_path,$file_name)
{
    $target_dir = $store_path;

    $temp = explode(".",$_FILES[$file_name]["name"]);
    $newfilename =trim($temp[0]).round(microtime(true)) . '.' . end($temp);
 

    $target_file = $target_dir .$newfilename;
    $error=$success="";
    $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
    // Check if image file is a actual image or fake image
    
    // Check if file already exists
    if (file_exists($target_file)) {
        $error="Sorry, file already exists.";
    }
    // Check file size
    if ($_FILES[$file_name]["size"] > 500000000) {
        $error="Sorry, your file is too large.";
    }
    // Allow certain file formats
    if($imageFileType != "pdf" ) {
        $error="Sorry, only pdf  files are allowed.";
    }
     if(!is_writable($store_path))
     {
      $error='You cannot upload to the specified directory, please CHMOD it to 777.';
     }
    // Check if $uploadOk is set to 0 by an error
    if ($error =="") {
        if (move_uploaded_file($_FILES[$file_name]["tmp_name"], $target_file)) {
            $success=$newfilename;
        } else {
            $error="Sorry, there was an error uploading your file.";
        }
    }
    if($success!="")
    {
      return json_encode(array('status'=>'success','msg'=>$success));
    }
    return json_encode(array('status'=>'error','msg'=>$error));

}
?>