'i create a download function for an image but its extension is come as .php

hi guys thank in advance for the answer I created a function where the user can download an image it work fine the image get downloaded but its extension come as .PHP eg(image.php) take a look at the code

just so you know it's only for images and I have tried (Content-Type: image/png) same result also if I change the extension of the download image back to jpg or png then the image open fine

if(isset($_GET['id'])){

    $id=$_GET['id'];
    $file="SELECT * FROM jobapplication where id = $id";
    $file_q=mysqli_query($conn,$file);
    $file_run=mysqli_fetch_assoc($file_q);

    $file=$file_run['cvfile'];


    $path= '../cv/' . $file;

    if(file_exists($path)){
        header('content-Description: File Transfer');
        header('content-Type: application/octet-stream');
        header("content-Disposition: attachment; filename'' ".basename($path))."";
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-length:'.filesize('../cv/' . $file));
        readfile('../cv/' . $file);
        exit();


    }else{

    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source