作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
<分区>
我使用以下代码和函数强制下载文件,如果文件名不包含瑞典语字符(如 Å Ä Ö
),它会很好用。
$file_id = $_GET['f'];
$sql = " SELECT * ".
" FROM attachment ".
" WHERE attachment_id = ".$file_id." ".
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
$filename = $row['filename'];
$USER_ID = $row['user_id'];
$Directory_id = $row['directory_id'];
$target_path = "upload/".$USER_ID."/".$Directory_id."/";
function Download($path, $speed = null)
{
if (is_file($path) === true)
{
$file = @fopen($path, 'rb');
$speed = (isset($speed) === true) ? round($speed * 1024) : 524288;
if (is_resource($file) === true)
{
set_time_limit(0);
ignore_user_abort(false);
while (ob_get_level() > 0)
{
ob_end_clean();
}
header('Expires: 0');
header('Pragma: public');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . sprintf('%u', filesize($path)));
header('Content-Disposition: attachment; filename="' . basename($path) . '"');
header('Content-Transfer-Encoding: binary');
while (feof($file) !== true)
{
echo fread($file, $speed);
while (ob_get_level() > 0)
{
ob_end_flush();
}
flush();
sleep(1);
}
fclose($file);
}
exit();
}
return false;
}
Download($target_path.$filename);
我试着把它放在我页面的顶部:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
和:
$filename = urlencode($filename);
或者:
$filename = htmlentities($filename, ENT_QUOTES, "UTF-8");
还是一样的问题,打不开。但如果文件名包含正常的英文字符,则它可以正常工作。
您有什么建议可以放入或实现该功能吗?非常感谢您提供的任何帮助。
我想知道如何通过 JavaScript 解决这个问题,我正在尝试将 id="needs-confirm-sweden"的复选框字段设为必需,只要将“Sweden”一词插入到输入国家字段。关于如何实现这
我的正则表达式有问题。我已经可以验证正确的瑞典社会安全号码以符合这些标准。 YYMMDDNNNN YYMMDD-NNNN YYYYMMDDNNNN YYYYMMDD-NNNN 但如果用户未满 18 岁
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我是 PHP 的新手,我正在开发一个非常小的项目来可视化从我们的自动车牌阅读器 (Openalpr) 到我们的叉车的车牌,以显示已到达装载区(区域 2)的货车 一切都在 Ubuntu 16.04.1
我有这个 View 源代码,它是在一台装有 SQL Server 2012 和 Latin1 服务器和数据库整理的机器上编写的: SELECT TOP 100 PERCENT W.Abteilun
我是一名优秀的程序员,十分优秀!