File "upload-txt.php"

Full Path: /home/u165092617/domains/tadzz.com/public_html/admin/upload-txt.php
File size: 1.04 KB
MIME-type: text/x-php
Charset: utf-8

<?php

// uploading files on submit
if(isset($_POST['submit'])){ 
  
    //  uploading files
    $msg= upload_file(); 
    session_start();
    $_SESSION['msgg']= $msg;
    header('location:text-file-upload.php');

}


function upload_file(){

    $uploadTo = ""; 
    $allowFileType = array('txt');
    $fileName = $_FILES['file']['name'];
    $tempPath=$_FILES["file"]["tmp_name"];
   


    $basename = basename($fileName);
    $originalPath = $uploadTo.$basename; 
    $fileType = pathinfo($originalPath, PATHINFO_EXTENSION); 

    if(!empty($fileName)){ 
    
       if(in_array($fileType, $allowFileType)){ 

         // Upload file to server 
         if(move_uploaded_file($tempPath,$originalPath)){ 

            return $fileName." was uploaded successfully";

           // write here sql query to store image name in database
          
          }else{ 
            $error = 'File Not uploaded ! try again';
          } 
      }else{
         return $fileType." file type not allowed";
      }
   }else{  
    return "Please Select a file";
   }       

}
?>