php 다운로드된 파일이 열리고도 표시가 재대로 안되는 오류

물어볼곳이 없어서 고심끝에 이쪽에한번 문의해봅니다

버추얼박스로 가상머신 centos 6.5 윈 7 에서 하고있습니다.

 djqfhem3743524199_1550145514.2833.png3743524199_1550145524.4189.png

 

3743524199_1550145712.5846.png

 

3743524199_1550145728.5304.png

답변 1개

코드소스입니다 ㅠㅠ

 

Copy
<?php

 

    header("Content-type: text/html; charset=utf-8");

 

    if(!$_GET['num'])

    {

        echo "<script>alert('이상하게 접근하셨습니다;;');";

        echo "history.back();</script>";

    }

    

    @ $db = new mysqli('DB호스트', 'DB계정명', 'DB계정비밀번호', '사용할DB');

    if(mysqli_connect_errno())

    {

        echo "DB connect error";

        exit;

    }

    

    $query = "select name, hash from ftp where num=".$_GET['num'];

    $result = $db->query($query);

    if(!$result)

    {

        echo "query error";

        exit;

    }

    $result = $result->fetch_assoc();

    

    $dir = "./files/";

    $filename = $result['name'];

    $filehash = $result['hash'];

    

    if(file_exists($dir.$filehash))

    {

            header("Content-Type: Application/octet-stream");

            header("Content-Disposition: attachment; filename=".$filename);

            header("Content-Transfer-Encoding: binary");

            header("Content-Length: ".filesize($dir.$filehash));

 

            $fp = fopen($dir.$filehash, "rb");

            while(!feof($fp))

            {

                echo fread($fp, 1024);

            }

            fclose($fp);

            

            $query = "update ftp set down=(down+1) where num=".$_GET['num'];

            $result = $db->query($query);

            if(!$result)

            {    

                echo "down counter update error";

                exit;

            }

    }

    else

    {

            echo "<script>alert('파일이 없습니다.);";

            echo "history.back();</script>";

            exit;

    }

    $db->close();

    

?>
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고