ok so im making an upload script, but i want only .txt files, to be allowed to be uploaded here is my script, what should i add to make it so only .txt files are uploaded...
<font size="4">Here you can upload your file it must be in a .txt. The max size is 50kilobytes.</font>
$_max_file_size = '51200'; //file size in bytes.
$upload_dir = "uploads/"; //upload folder..chmod to 777
echo "Maximum file size : " . $_max_file_size/1000 . "KB<br>";
echo "<form enctype='multipart/form-data' action='?do=upload' method='post'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='" . $_max_file_size , "'>";
echo "Choose a file to upload: <input name='filename' type='file'>";
echo "<input type='submit' value='Upload File'>";
if($_GET['do'] == 'upload')
$_random = rand(1, 1000000);
$target_path = $upload_dir . $_random . basename($_FILES['filename']['name']);
$_file_name = $_random . basename($_FILES['filename']['name']);
echo "The file " . $_file_name . " has been uploaded.";
echo "There was an error uploading the file, please try again! Maybe be the file size. Maximum file size is " . $_max_file_size/1000 . "KB";