$maxsize) die('Filen du valde är för stor. Maxstorleken är '.(string)($maxsize/1024).' KB.'); $types = explode(',', $filetypes); $file = explode('.', $_FILES['uplfile']['name']); $extension = $file[sizeof($file)-1]; if(!in_array(strtolower($extension), $types)) die('Du har en felaktig filtyp. Endast .jpg, .gif och .png är tillåtet!'); $bokstav = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6'); $thefile = $_FILES['uplfile']['name']; while (file_exists($upload_dir.$thefile)) { $img = $bokstav[rand(0, count($bokstav)-1)].$thefile; } if (is_uploaded_file($_FILES['uplfile']['tmp_name']) && move_uploaded_file($_FILES['uplfile']['tmp_name'],$upload_dir.$thefile)) { echo 'Filen laddades upp!'; } else { echo 'Ett fel uppstod och filen kunde inte laddas upp.'; } } else { ?>
Fil: 

Listing
' . $file . ' ' . round(filesize("upload/".$file)/1024,1) . ' Kb
'; } } closedir($handle); } ?>