php 手机端下载文件及上传文件

TomyGuan 2016-03-25 06:23:35
用PHP实现了在电脑端的上传及下载文件,但在手机端完全不能使用,大伙给个想法或源码,谢谢!

下载在电脑端是这样实现的,但在手机端不能用
ob_start();
$this->image();
$s = ob_get_clean();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
//header("Content-type:application/octet-stream;");
header("Accept-Ranges:bytes");
header("Content-Type:text/html;charset=utf-8");
header('Content-Length: '.strlen($s));

$ua = $_SERVER["HTTP_USER_AGENT"];

$filename = “abc.jpg";

$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);

if (preg_match("/MSIE/", $ua)) {
header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');
} else if (preg_match("/Firefox/", $ua)) {
header('Content-Disposition: attachment; filename*="utf8\'\'' . $filename . '"');
} else {
header('Content-Disposition: attachment; filename="' . $filename . '"');
}
header("Content-Transfer-Encoding: binary");
echo $s;

...全文
332 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
最后的诗人 2016-03-30
  • 打赏
  • 举报
回复
为什么要这么复杂,直接给个图片的链接地址不行吗?

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧