文件下载出错

时间:2013-11-21 04:29:29

标签: php wordpress security download

大家好我正在尝试安全文件下载,但我不知道什么是issu,为什么我的代码在这里找不到文件代码,它总是显示“找不到文件”

这是DOWNLOAD.php

<?php require('wp-config.php');

$file = $_GET['filename'];

$sql = "Select * From wp_paypal_responders Where att_secure =
'$file'"; $qry = mysql_query($sql); $obj = mysql_fetch_object($qry);
$fileName = $obj->att_secure;
$download_dir = $_SERVER['HTTP_HOST'].'/uploads/';
$fullPath = $download_dir.$fileName;
// Required for some browsers   if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
// File Exists?   if( file_exists($fullPath) ){  
header("Content-Disposition: attachment; filename=".$fullPath);
header("Content-Description:File Transfer");
header('Content-Transfer-Encoding: binary');    
header('Cache-Control:must-revalidate, post-check=0, pre-check=0'); 
header('Pragma:public'); 
header('Content-Type: application/octet-stream');
readfile( $fullPath );
} else
die('File Not Found');
?>

,这是Index.php

<table class="widefat posts" cellspacing="0" style="margin-top:20px;">

    <thead>

    <tr>

        <th scope="col" width="30%"><a href="javascript:;">Responder</a></th>

        <th scope="col" width="30%"><a href="javascript:;">From</a></th>

        <th scope="col" width="20%"><a href="javascript:;">Subject</a></th>

        <th scope="col" width="35%"><a href="javascript:;">Attachment</a></th>

        <th scope="col" width="10%"><a href="javascript:;">Edit</a></th>    

        <th scope="col" width="10%"><a href="javascript:;">Delete</a></th>  

    </tr>

    </thead>

    <tfoot>

    <tr>

        <th scope="col" width="30%"><a href="javascript:;">Responder</a></th>

        <th scope="col" width="30%"><a href="javascript:;">From</a></th>

        <th scope="col" width="20%"><a href="javascript:;">Subject</a></th>

        <th scope="col" width="35%"><a href="javascript:;">Attachment</a></th>

        <th scope="col" width="10%"><a href="javascript:;">Edit</a></th>    

        <th scope="col" width="10%"><a href="javascript:;">Delete</a></th>      

    </tr>

    </tfoot>

    <tbody>

         <?php

        $sql = "SELECT * FROM $table";

        $results = $wpdb -> get_results($sql);

        ?>

    <?php if( !empty( $results ) ) : ?>

    <?php foreach( $results as $result ): ?>

        <tr>

            <td><?php echo $result -> resp_name; ?></td>             

            <td><?php echo $result -> from_email; ?></td>

            <td><?php echo $result -> subject; ?></td>

            <td><a href="<?php echo get_bloginfo('siteurl'); ?>/download.php?filename=<?php echo $result -> att_secure; ?>"><?php echo $result -> att_name; ?></a></td>

          <td><a href="admin.php?page=file&action=update&id=<?php echo $result -> id; ?>">Update</a></td>

            <td><a href="admin.php?page=file&action=delete&id=<?php echo $result -> id; ?>">Delete</a></td>

        </tr>

        <?php endforeach; ?>



    <?php else: ?>

    <tr>

        <td colspan="5">No Responders</td>

    </tr>

    <?php endif; ?>

    </tbody>

  </table>

0 个答案:

没有答案