我正在尝试.dwg
使用以下代码强制下载文件:
$filename = $_GET['f'];
$upload_path = wp_upload_dir();
$src = $upload_path['basedir'] . '/' . $filename;
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header("Content-disposition: attachment; filename=\"{$filename}\"");
header("Content-Type: application/octet-stream");
header('Content-Transfer-Encoding: binary');
readfile($src);
die();
该文件的路径是正确的,但它只返回一个6 字节且无法打开的文件。它应该是754 字节。任何人都可以在这里帮助我吗?
//Example file
$src = "/var/www/wp/wp-content/uploads/Glasparti-modell-Silence.dwg";