<?php
include("../../pidbco/pidbjoin.php");

if(isset($_FILES['file']))
{
    $ord_id = strip_tags(base64_decode($_POST['od']));
    $name = $_FILES['file']['name'];
    $tmp_name = $_FILES['file']['tmp_name'];
    $type_name = $_FILES['file']['type'];
    $error = $_FILES['file']['error'];

    if(!empty($name))
    {

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

        for($i=0;$i<count($tmp_name);$i++)
        {

                        $u_name= time().'_'.rand(100,999).$name[$i];
                        move_uploaded_file($tmp_name[$i],'../material-uploads/'.$u_name);
                        mysqli_query($con,"INSERT INTO ord_materials(ord_id, upload_date, datas) VALUES ('$ord_id','$date','$u_name')");
                        ?><script>window.location.href="Marketing-Order-Details";</script><?php

         }

    }
    else
    {
        ?><script>alert('Error..!');</script><?php
    }

}

?>