如何创建一个下载链接,它将在ios和Android设备上运行

时间:2016-04-15 08:20:17

标签: android ios download

想要创建文件的下载链接,但它仅适用于不在IOS和Android设备中的桌面浏览器。

我是如何用php,jquery等实现的?

这是我试过的

<?php
 $filename = $_GET['file'];
 if (isset($filename)) 
{
// Prevents someone from trying to access something that is not in the same directory as this script
if(substr_count($filename,"/") > 0)
{
die('error');
}; 
$len = filesize($filename);
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-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.$len);
readfile($filename);
}
else
{
die('No file specified.'); 
};
?>

由于

0 个答案:

没有答案