function uploadFile()
 {
     $uploadFileTimeStart = microtime(true);
     $target_dir = "C:\\xampp\\htdocs\\BEPROJECT\\Html\\Text/";
     $my_file = $_FILES["fileToUpload"]["name"];
     $target_file = $target_dir . basename($my_file);
     $FileType = pathinfo($target_file, PATHINFO_EXTENSION);
     try {
         // Undefined | Multiple Files | $_FILES Corruption Attack
         if (!isset($_FILES['fileToUpload']['error']) || is_array($_FILES['fileToUpload']['error'])) {
             throw new RuntimeException('<h2>Invalid parameters.</h2>');
         }
         // Check $_FILES['fileToUpload']['error'] value.
         switch ($_FILES['fileToUpload']['error']) {
             case UPLOAD_ERR_OK:
                 break;
             case UPLOAD_ERR_NO_FILE:
                 throw new RuntimeException('<h2>No file sent.</h2>');
             case UPLOAD_ERR_INI_SIZE:
             case UPLOAD_ERR_FORM_SIZE:
                 throw new RuntimeException('<h2>Exceeded filesize limit.</h2>');
             default:
                 throw new RuntimeException('<h2>Unknown errors.</h2>');
         }
         // Check if file already exists
         if (file_exists($target_file)) {
             throw new RuntimeException('<h2>File Already Exist in root directory.</h2>');
         }
         // Allow certain file formats
         if ($FileType != "txt") {
             throw new RuntimeException('<h2>Only Text files Allowed!</h2>');
         }
         //check filesize.
         if ($_FILES['fileToUpload']['size'] > 1000000) {
             throw new RuntimeException('<h2>Exceeded filesize limit.</h2>');
         }
         //obtain safe unique name from its binary data.
         if (!move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_file)) {
             throw new RuntimeException('<h2>Failed to move uploaded file.</h2>');
         }
         echo '<h2>File is uploaded successfully.</h2>';
     } catch (RuntimeException $e) {
         echo $e->getMessage();
     }
     $uploadFileTimeEnd = microtime(true);
     $totalTimetoUploadFiles = $uploadFileTimeEnd - $uploadFileTimeStart;
     $_SESSION['uploadFile_time'] = $totalTimetoUploadFiles;
     $readFileContentsTimeStart = microtime(true);
     $handle = fopen("C:\\xampp\\htdocs\\BEPROJECT\\Html\\Text/" . $my_file, "r") or die('Cannot open file: ' . $my_file);
     $filesize = filesize("C:\\xampp\\htdocs\\BEPROJECT\\Html\\Text/" . $my_file);
     $contents = fread($handle, $filesize);
     $readFileContentsTimeEnd = microtime(true);
     $totalTimetoReadFiles = $readFileContentsTimeEnd - $readFileContentsTimeStart;
     $_SESSION['readTextFile_time'] = $totalTimetoReadFiles;
     $count_words = str_word_count($contents);
     //for calculating term frequency
     $words = extractCommonWords($contents, $filesize);
     //extracting keywords
     $id = getID($my_file, $filesize);
     //generating id
     toDatabase($id, $words, $count_words);
     //inserting to database
     display($my_file, $contents);
     //displaying final contents
 }
 function readContents($filename, $FileType)
 {
     $readFileContentsTimeStart = microtime(true);
     $var = $FileType;
     $myfile = $filename . "_" . $var . ".txt";
     //extracting contents of entire mumtimedia
     $actualName = $filename . "." . $FileType;
     $fullhandle = fopen("C:\\xampp\\htdocs\\BEPROJECT\\Html\\Multimedia/" . $actualName, "r") or die("cannot create file!");
     $fullFilesize = filesize("C:\\xampp\\htdocs\\BEPROJECT\\Html\\Multimedia/" . $actualName);
     $fullContents = fread($fullhandle, $fullFilesize);
     encryptData($fullContents, $actualName);
     //extracting contents of text enter while uploading MM
     $contents = $_POST['comment'];
     $handle = fopen("C:\\xampp\\htdocs\\BEPROJECT\\Html\\Multimedia/" . $myfile, "w") or die("cannot create file!");
     fwrite($handle, $contents);
     $filesize = filesize("C:\\xampp\\htdocs\\BEPROJECT\\Html\\Multimedia/" . $myfile);
     $readFileContentsTimeEnd = microtime(true);
     $totalTimetoReadFiles = $readFileContentsTimeEnd - $readFileContentsTimeStart;
     $_SESSION['readMMFile_time'] = $totalTimetoReadFiles;
     $count_words = str_word_count($contents);
     //for calculating term frequency
     $words = extractCommonWords($contents, $filesize);
     //extracting keywords
     $id = getID($myfile, $filesize);
     //generating id
     toDatabase($id, $words, $count_words);
     //inserting to database
     display($myfile, $contents, $filesize);
     //displaying final contents
 }