Image Upload PHP Core or OOPs

'jobseeker_photo' is the name  of the input 


$file = $FILES['jobseeker_photo'];

        

        $fileName = $_FILES['jobseeker_photo']['name'];

        $fileTmpName = $_FILES['jobseeker_photo']['tmp_name'];

        $fileSize = $_FILES['jobseeker_photo']['size'];

        $fileError = $_FILES['jobseeker_photo']['error'];

        $fileType = $_FILES['jobseeker_photo']['type'];

        

        $fileExt = explode('.', $fileName);

        $fileActualExt = strtolower(end($fileExt));

        

        $allowed = array('jpg', 'jpeg', 'png');

      

        

        if(in_array($fileActualExt, $allowed)) {

            if($fileError === 0){

                if($fileSize < 1000000) {

                    $fileNameNew = uniqid('', true).".".$fileActualExt;

                    $fileDestination = 'uploads/'.$fileNameNew;

                    move_uploaded_file($fileTmpName, $fileDestination);

                    header("location:form.php?success");

                }

                else {

                    echo "Image File is too big to be uploaded.";

                }

                

            }

            else {

                echo "Error in uploading image file.";

            }

            

        }

        else {

            echo "The image Files of this type could not be uploaded!";

        }

Comments

Popular posts from this blog

Xampp Customization

Complete Class to Insert Data and Upload Image in PHP OOPS