【发布时间】:2012-03-13 01:03:21
【问题描述】:
我知道这方面有很多问题,但我没有发现任何特定于移动设备的问题。
由于某些原因,我不能在“主”页面上使用 php,所以我通过 jQuery $.get 完成了
它工作正常,除了下载时,我使用 1x1 iframe 开始下载,工作正常.. 除了在 iphone + Galaxy s2 上(我在 atm 上测试过的唯一 2 个)
我在页面上的代码被 iframe 调用:
<?
$email = mysql_escape_string($_GET['email']);
$code = mysql_escape_string($_GET['code']);
include('xxxxx.php');
mysql_select_db($xxxxx);
$now = strtotime(date('c'));
$sql = mysql_query("SELECT * FROM `xxxxx` WHERE `email` = '$email' AND `code` = '$code'");
if(mysql_num_rows($sql) == 0) { echo "<script>alert('Incorrect Code');</script>"; die; }
$query = mysql_fetch_object($sql);
if(strtotime($query->expires) > $now) {
$filename = "theused.wav";
header('Content-type: audio/x-wav');
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
header('Content-Transfer-Encoding: binary');
readfile('http://www.something.co.uk/xxx/' . $filename);
} else {
echo "<script>alert('Code Expired');</script>"; die;
}
?>
直接访问此页面时下载工作正常,但在 iFrame 上打开时就不行
变得更奇怪...只是尝试做一个 window.location 代替,当连接到 wifi 时它失败并说下载不成功,在 3g 上似乎工作正常。
【问题讨论】:
-
$filename 是您的网络服务器本地的吗?在这种情况下不要使用完整的 url - 当只需要一个简单的本地文件 i/o 操作时,你会强制完成另一个 hTTP 请求。
-
我必须使用最愚蠢的店面组合之一。我必须绝对路径几乎所有东西。无论如何,这并不能解决我的问题
标签: php iframe mobile download