File: /var/www/BtMiners/BtMiners-store/show_img.php
<?php
if (empty($_GET['file'])) {
exit;
}
// var_dump($_GET['file']);exit;
// 获取文件路径
$file_name = $_GET['file'];
$file_name = str_replace('https://bt-miners.com/wp-content/uploads/transaction_certificate/','',$file_name);
$file_name = str_replace('https://www.bt-miners.com/wp-content/uploads/transaction_certificate/','',$file_name);
$file_name = str_replace('https://testing-25.bt-miners.com/wp-content/uploads/transaction_certificate/','',$file_name);
$upload_dir = './wp-content/uploads/transaction_certificate/';
$full_path = $upload_dir . $file_name;
// 安全检查
if (!file_exists($full_path) || !is_file($full_path)) {
echo '文件不存在';
exit;
}
// 获取文件的 MIME 类型
$mimeType = mime_content_type($full_path);
header('Content-Type: ' . $mimeType);
// var_dump($mime['type']);
header('Content-Length: ' . filesize($full_path));
// var_dump(filesize($full_path));
readfile($full_path);
exit;
?>