<?php
 
function SubmitImage($files, $renameFile, $fileLocation)
{


    $fileName = $files['name'];
    $fileTmpName = $files['tmp_name'];
    $fileSize = $files['size'];
    $fileError = $files['error'];
    $fileType = $files['type'];



    //now we will code the type of file we want to allow to be uploaded 

    $fileExt = explode('.', $fileName);
    $fileActualExt = strtolower(end($fileExt)); //the end get the last piece of data in an array 

    //creating an array of the information we want to allow 
    $allowed = array('jpg', 'jpeg', 'png', 'pdf');

    if (in_array($fileActualExt, $allowed)) {
        if ($fileError === 0) {
            if ($fileSize < 50000000) {
                // main upload file code 
                // we have to rename it so that it will not have same name for different images
                global $fileNameNew;
                $fileNameNew =  $renameFile . "." . $fileActualExt;
                $fileDestination = $fileLocation . '/' . $fileNameNew;
                //main upload code
                // move_uploaded_file($fileTmpName, $fileDestination);

                if (move_uploaded_file($fileTmpName, $fileDestination)) {
                    echo ' ';
                }
            }
        }
    } else {
        echo 'error check your file ';
    }

    return $fileNameNew;
}
// end function


// this function is to format all numbers 
