我的上传/下载过程有一些问题。我的文件作为 BLOB 插入到 mysql 中,但是下载时它会抓取调用 php 页面的 html 标记。在插入数据库之前,我是否需要将上传的文件移动到临时目录?
编辑:当前的 upload.php 文件。仍然获得 html 内容而不是实际文件本身,它仍然被正确命名。
           <?php
                    // Make sure an ID was passed DOWNLOAD HANDLER *******
if(isset($_GET['id'])) {
// Get the ID
    $id = intval($_GET['id']); var_dump($id);
    require_once ('../mysqli_connect.php'); //Connect to the db
        // Fetch the file information
        $downloadq = "
            SELECT `file_type`, `size`, `title`, 'content', 'upload_id'
            FROM `upload`
            WHERE `upload_id` =".$id;
        $result = mysqli_query ($dbc, $downloadq); // Run the query
        if($result) {
            // Make sure the result is valid
            if (mysqli_num_rows($result) > 0) {
            // Get the row
                $row = mysqli_fetch_assoc($result);
                //var_dump($row);
                // Print headers
                header("Content-Type: application/msword");
                header("Content-Length: ". $row['size']);
               header("Content-Disposition: attachment; filename=". $row['title']);
               header("Content-Transfer-Encoding: binary");
                // Print data
                echo (stripslashes($row['content']));
            }
            else {
                echo 'Error! No such ID.';
            }
            // Free the mysqli resources
            mysqli_free_result($result);
        }
        else {
            echo "Error! Query failed: <pre>{$dbc->error}</pre>";
        }
        mysqli_close($dbc);
}
                ?>