当前位置:   article > 正文

php 文件下载路径不对,php – 用户下载文件时隐藏文件夹路径

php view.js插件怎样隐藏pdf路径

PDF文档示例

$nameOld = "/public_html/wp-content/example.folder/oldnme.pdf";

$nameNew = "newName.pdf" ;

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

header('Content-type: application/pdf');

header("Content-disposition: attachment; filename=$nameNew"); //

readfile($nameOld);

编辑

使用download.php验证图像系统的概念?img =没有扩展名的花和花展是图像名称

$directory = "/public_html/wp-content/example.folder/";

$types = array("jpg","gif","png");

$ext = null;

if (! isset($_GET['img'])) {

die("Invalid URL");

}

$nameOld = filter_var($_GET['img'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW);

$nameNew = uniqid(basename($nameOld));

// File the file

foreach ( $types as $type ) {

if (is_file($nameOld . "." . $type)) {

$ext = $type;

break;

}

}

if ($ext == null) {

die("Sorry Image Not Found");

}

$nameOld .= "." . $ext;

$type = image_type_to_mime_type(exif_imagetype($nameOld));

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

header('Content-type: ' . $type);

header("Content-disposition: attachment; filename=$nameNew"); //

readfile($nameOld);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/338489
推荐阅读
相关标签
  

闽ICP备14008679号