"gif", "image/png" => "png", "image/bmp" => "bmp", "image/jpeg" => "jpg", "video/3gpp" => "3gp", "video/mp4" => "mp4", "video/x-ms-wmv" => "wmv", "video/webm" => "webm", "video/x-msvideo" => "avi", "text/plain" => "txt", "text/html" => "html", "audio/mpeg" => "mp3", "audio/vnd.wav" => "wav", "audio/x-m4a" => "m4a" // Add more types here if you like ); // Check to see if file is an allowed extension if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("You are trying to upload unsupported file type (Only: gif, png, bmp, jpg, mp4 and pdf is supported)"); }else{ $uploaddir = "aof/"; // What is the files temporary name? $file = htmlspecialchars($_FILES['userfile']['tmp_name']); $file=strtok($file, "#"); // What is the files actual name? $filename = htmlspecialchars($_FILES['userfile']['name']); $filename=strtok($filename, "#"); // Check to see if the file allready exists? if(file_exists($uploaddir . $filename)) { // rename the file if exist and store //$random_number = random_int(100000, 999999); //$filename = $random_number."_".$filename; $random_number = rand(100000, 999999); $filename ="$random_number$filename"; $fn = $filename; copy($file, $uploaddir.$filename) or die("Could not upload picture."); //die("A file with that name already exists on this server, please rename the file."); }else{ // If the file does not already exist, copy it. $fn = $filename; copy($file, $uploaddir.$filename) or die("Could not upload picture."); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //THIS ASPECT RESIZES IMAGES SO AS NOT TO HAVE AN OVERSIZED IMAGE IN THE LIBRARY /* $allowed_images = array( "image/gif" => "gif", "image/png" => "png", "image/bmp" => "bmp", "image/jpeg" => "jpg" ); if(!array_key_exists($_FILES['userfile']['type'], $allowed_images)) { // *** Include the class include("resize-class.php"); $ResizeFile = "piks/".$filename; //$ResizeFile = $file; // *** 1) Initialise / load image $resizeObj = new resize($ResizeFile); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) //$resizeObj -> resizeImage(220, 280, 'crop'); $resizeObj -> resizeImage(700, 700, 'auto'); // *** 3) Save image $resizeObj -> saveImage($ResizeFile, 220); //$file = $ResizeFile; } */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } } ?>