<?Php

function formatBytes($bytes, $precision = 2) {
    $units = array('B', 'KB', 'MB', 'GB', 'TB');
  
    $bytes = max($bytes, 0);
    $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
    $pow = min($pow, count($units) - 1);
  
    $bytes /= pow(1024, $pow);
  
    return round($bytes, $precision) . ' ' . $units[$pow];
}

//define the path as relative
$path = "../uploads";

//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");

echo " ";

while ($file = readdir($dir_handle)) 
{
   
if($file!="$file.avi" && $file!="$file.srt")
if($file!="." && $file!="..")
if($file != "play.php")
if($file != "index.html")

function remove_file()
 // not working :(
   if($_GET['action'] && $_GET['action'] == 'delete') {
       unlink($_GET['filename']);
       header("$path."/".$file");
       exit();
   }

    echo $file . ': ' . formatBytes(filesize($path."/".$file), 2) . ' </a> <a href="$path."/"?action=delete&filename=.$file">delete file</a><br/>';
}


//closing the directory
closedir($dir_handle);

?>