Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在webroot php readfile之外存储上传的图像速度非常慢_Php_Security_File Upload_Readfile - Fatal编程技术网

在webroot php readfile之外存储上传的图像速度非常慢

在webroot php readfile之外存储上传的图像速度非常慢,php,security,file-upload,readfile,Php,Security,File Upload,Readfile,出于安全原因,我正在测试一种在webroot之外存储上传内容的新方法,我在一些问题中看到了这一点 我让一切正常运行,包括我的TimThumb文件,但我注意到这大大增加了页面加载时间。我在大多数页面上都有许多用户上传的图像,当通过webroot以外的readfile()获取它们时,加载时间是无法忍受的 有什么我遗漏的吗?我想保证安全,但我实在负担不起这么长的加载时间 我的图像处理脚本如下所示: $queryString = str_replace('.php&', '.php?', $_S

出于安全原因,我正在测试一种在webroot之外存储上传内容的新方法,我在一些问题中看到了这一点

我让一切正常运行,包括我的TimThumb文件,但我注意到这大大增加了页面加载时间。我在大多数页面上都有许多用户上传的图像,当通过webroot以外的
readfile()
获取它们时,加载时间是无法忍受的

有什么我遗漏的吗?我想保证安全,但我实在负担不起这么长的加载时间

我的图像处理脚本如下所示:

$queryString = str_replace('.php&', '.php?', $_SERVER['QUERY_STRING']);

$src = preg_replace('#^src=#', '', $queryString);
$path = slash($_SERVER['DOCUMENT_ROOT'].'/../'.$src); // slash() removes duplicate slashes

if ( stristr($src, 'thumb.php') ) {
    // output the thumb file
    $query = explode('?', $path);
    $urlVars = explode('&', $query[1]);

    // storing TimThumb query vars as SESSION vars to pass them
    foreach($urlVars as $var) {
        $parts = explode('=', $var);
        $_SESSION['Thumb']['Thumb-'.ucwords($parts[0])] = $parts[1];
    }
    $path = str_replace('?'.$query[1], '', $path);
    echo include_php_file($path); // include_php_file just saves the buffered output from a file so you can use it as a var
    return;
} else {
    // output the image
    header('Content-Type: image/jpeg');
    echo readfile($path);
    return;
}