<?php  
 include_once 'opendb.php';

 $content =file_get_contents($_FILES['file']['tmp_name']);
    $content = addslashes($content);        
 //$numUploadedfiles = count($_FILES['file']['tmp_name']);
  
    $FileName=$_GET["FileName"];
               $ReqID=$_GET["ReqID"];
           //   echo $FileName." - ". $ReqID;
              
             // print_r( $_GET); 
            
  //print_r( $_FILES);      $data = $dbLink->real_escape_string(file_get_contents($_FILES  ['uploaded_file']['tmp_name']));

  if (isset($_GET["ReqID"]) && isset($_GET["FileName"]) )
    {       
               $FileName=$_GET["FileName"];
               $ReqID=$_GET["ReqID"];
              
              $sql = "SELECT * FROM client_requests WHERE request_id = ".$ReqID.";";
              $result = $conn->query($sql);
              if ($result->num_rows > 0 )
              { 
               $sql = "UPDATE client_requests SET file_data='".$content."',file_name='".$FileName."',req_status=1 WHERE request_id=".$ReqID.";";
        
                        if ($conn->query($sql) === TRUE) {
                            echo( "Uploaded");
                        } else {
                            echo( "Error updating request: " . $conn->error);
                        }
              }
              else 
              {
                  echo( "Error updating request, invalid request id " . $ReqID);
              }
              $conn->close();
              
            
    
    }
    
    
    
    
 ?>