<?php 	
session_start();
require_once '../../Server/connection.php';
include('../includes/session.php');
if($_POST){
  $payment_id = $_POST['payment_id'];
  
 
	
	if(!empty($_FILES['file']['name'])){
	foreach ($_FILES['file']['name'] as $key => $name){
		$newFilename = time() . "_" . $name;
		move_uploaded_file($_FILES['file']['tmp_name'][$key],'../../files/'.$newFilename);
		$location = '../../files/' . $newFilename;
		
		mysqli_query($conn,"insert into collected_payments_docs (payment_id,fileName) values ('$payment_id','$location')");
		
	          }
	          }
			  
			  
   
	$_SESSION['success_message'] = "File Has Been Uploaded Successfully";
                        header("Location: ../add_Files.php");
                             exit();
     
	
}