0){ //echo $_FILES['file1']['size']."SIZE"; if($_FILES['file1']['size']>$maxfilesize) { echo "File too big!"; } else{ $totalsize=0; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(filetype($dir . $file)=="file") { $file_names[] = $file; $file_dates[] = filectime($dir.$file); $file_sizes[] = filesize($dir.$file); $totalsize=$totalsize+filesize($dir.$file);} } closedir($dh); } } asort($file_dates); $file_names_Array = array_keys($file_dates); foreach ($file_names_Array as $idx => $name) $name=$file_names[$name]; $file_dates = array_merge($file_dates); $i = 0; foreach ($file_dates as $file_dates){ $date = date("D d-m-Y H:i:s",$file_dates); $j = $file_names_Array[$i]; $file = $file_names[$j]; $size = $file_sizes[$j]; $i++; if($totalsize+$_FILES['file1']['size']>$maxdirsize) { if($file!=basename($_SERVER['SCRIPT_NAME'])) { unlink($dir.$file); $totalsize=$totalsize-$size;} }else{break;} // break; } $p=pathinfo($_FILES['file1']['name']); $z=$p['extension']; echo "$z"; $renamefile=$dir.$_FILES['file1']['name']; if(in_array(strtolower($z),$addTxtExtensions)) $renamefile.=".txt"; // $arr_basename=explode(".",$_FILES['file1']['name']); // $file_type=$arr_basename[count($arr_basename)-1]; //echo "$z"; if(rename($_FILES['file1']['tmp_name'],$renamefile)) { echo $_FILES['file1']['name']." uploaded!"; }else{ //print_r($_FILES); } } } // function printDir($dir){ unset($file); unset($file_names); unset($file_dates); unset($file_sizes); $totalsize=0; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(filetype($dir . $file)=="file"){ if($file!=basename($_SERVER['SCRIPT_NAME'])){ $file_names[] = $file; $file_dates[] = filectime($dir.$file); $file_sizes[] = filesize($dir.$file); $totalsize=$totalsize+filesize($dir.$file); } }else{ //echo "dir".$file; $dir_names[] = $file; $dir_dates[] = filectime($dir.$file); $dir_sizes[] = filesize($dir.$file); //echo "[".$file."]<" } } closedir($dh); } } arsort($file_dates); $file_names_Array = array_keys($file_dates); foreach ($file_names_Array as $idx => $name) $name=$file_names[$name]; $file_dates = array_merge($file_dates); $i = 0; echo ""; //Loop through dates array and then echo the list reset($file_dates); foreach ($dir_names as $dir_names){ $date = date("D d-m-Y H:i:s",$dir_dates); $j = $dir_names_Array[$i]; $file = $dir_names; $size = $dir_sizes[$j]; $i++; if($file!=".") if ($size/1024/1024>1) echo ""; else echo ""; } $i=0; foreach ($file_dates as $file_dates){ $date = date("D d-m-Y H:i:s",$file_dates); $j = $file_names_Array[$i]; $file = $file_names[$j]; $size = $file_sizes[$j]; $i++; if ($size/1024/1024>1) echo ""; else echo ""; } echo "
[ $file ]".round(($size/1024/1024),1)."MB$date
[ $file ]".round(($size/1024),1)."KB$date
$file".round(($size/1024/1024),1)."MB$date
$file".round(($size/1024),1)."KB$date
"; if ($totalsize/1024/1024>1) echo "Total size: ". round(($totalsize/1024/1024),1)."MB
"; else echo "Total size: ". round(($totalsize/1024),1)."KB
"; echo "
"; //printDir(); ?>