Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ios和android设备上创建下载链接_Android_Ios_Download - Fatal编程技术网

如何在ios和android设备上创建下载链接

如何在ios和android设备上创建下载链接,android,ios,download,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

想要创建文件的下载链接,但它只能在桌面浏览器中工作,而不能在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.'); 
};
?>


谢谢

您所说的“不在iOS和Android设备中”是什么意思。您在iOS和Android上显示此链接的方式是什么?@Anahit DEV:web链接或web api不限于客户端平台:)服务器上运行的web服务:)可能是php、java、,ruby或python:)它们都在服务器上运行,而不是在客户端:)你所要做的就是读取文件并使用你的php脚本、java rest api或servlet或你能想到的任何其他服务器端代码对其进行流式处理:)然后在你的客户端应用程序点击api,逐块读取内容并将其存储在文件中,这就是你下载它的方式:)现在如果你的客户端只是浏览器而不是定制应用,所有android浏览器都可以下载内容:)根据ios中safari的说法:)我认为它不会下载任何内容:)所以如果你的浏览器不允许你下载内容,您在服务器端无法执行任何操作:)最后,一旦您编写了API,请在apple的postman插件中对其进行测试:)查看我编辑的问题@SandeepBhandari中的代码。有了这个php脚本,它就可以在桌面浏览器上工作,甚至在android上也可以,但在iphone等IOS设备上就不行了,它只是在新版本中打开的tab@anahit-戴夫:这就是我在第二条评论中说的,伙计:)你不能做任何事情让它在iOS设备上下载:)这是苹果强加的限制:)