小编Cra*_*cam的帖子

PHP Readfile()不适合我,我不知道为什么

我试图让这个代码工作,但由于某种原因,所有的回声都能够输出正确的内容,但标题似乎不想强制下载我的文档.以下是我试图为文件下载构建的文件.它被设置为输入如下代码:根据用户权限downloader.php?f=13&t=doc下载已命名的文件201-xxx.doc201-xxx.pdf从两个文件夹中的一个文件夹下载.

所有逻辑都适用于底部的标题信息.如果我注释掉标题内容类型和标题内容处置,那么它会将文件读入浏览器.如果包含这些行中的任何一行,它会给出一个错误"Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found."

<?php
//ob_start();
if ( !defined('__DIR__') ) define('__DIR__', dirname(__FILE__));
define( "TLOJ_FSROOT", __DIR__ . "/" );
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');

$lessonnumber = $_REQUEST['f'];
$type = $_REQUEST['t'];

    if ( $lessonnumber < '10' ) { $threedigitlesson = '00' . $lessonnumber; }
    elseif ( $lessonnumber < '100' ) { $threedigitlesson = '0' . $lessonnumber; }
    else { $threedigitlesson = $lessonnumber; }
    $filenamestart = "201-" . $threedigitlesson;

    $contenttype …
Run Code Online (Sandbox Code Playgroud)

php download readfile

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

download ×1

php ×1

readfile ×1