<? include('lock.php');?> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
include_once 'config.php';
if(isset($_POST['btn-upload']))
{    
     
 $file = rand(1000,100000)."-".$_FILES['file']['name'];
 $file_loc  = $_FILES['file']['tmp_name'];
 $file_size = $_FILES['file']['size'];
 $file_type = $_FILES['file']['type'];
 $dikaio    = $_POST['dikaio'];
 $folder="uploads/";
 
 // new file size in KB
 $new_size = $file_size/1024;  
 // new file size in KB
 
 // make file name in lower case
 $new_file_name = strtolower($file);
 // make file name in lower case
 
 $final_file=str_replace(' ','-',$new_file_name);
 
 if(move_uploaded_file($file_loc,$folder.$final_file))
 {
  $sql="INSERT INTO uploads(file,type,size,dikaio) VALUES('$final_file','$file_type','$new_size','$dikaio')";
  mysql_query($sql);
  ?>
  <script>
  alert('μεταφορτώθηκε με επιτυχία');
        window.location.href='upl.php?success';
        </script>
  <?php
 }
 else
 {
  ?>
  <script>
  alert('σφάλμα κατά τη μεταφόρτωση του αρχείου');
        window.location.href='upl.php?fail';
        </script>
  <?php
 }
}
?>