10秒后下载文件 [英] Download file after 10 seconds

查看:65
本文介绍了10秒后下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个包含文件链接的下载页面,我希望文件在10秒后自动下载,但是不确定如何执行此操作.文件的链接存储在cookie中,可以在下载页面上访问,并存储在$ file变量中.

该文件的链接将与此类似:

https://cloud1.taccess.co.uk/cloud/uploads/eed376ad76d1f74b597aa2e21121f7e6tantami_cloud_file_580a40c1eff3af7484ef592c10bff10047b373cdc5dfd.pptx?AWSAccessKeyId=aKIAJ56YO6753B2RUT2&M;4%1P1F1%3%B2RUT2Q&M;Payment%3%&3%&1%&3%&3%&3%&1%&3%&3%&1%&3%;1%&3%;1%&3%;1%&3%;1%&3%;1%&3%;p%&3

这指向文件,并包含要下载的文件所需的权限.简而言之,我正在寻找一种方法来使此链接在10秒后打开,以便可以下载文件.

谢谢

您的标签是php,所以我认为您想添加一些协议以供下载,我认为这是

将帮助您

  $ filename =您的文件名";标头(内容类型:应用程序/任何特定的标头");//设置标题//您的内容sleep(10)//将增加10秒的延迟header("Content-Disposition:附件; filename = $ file_name");//将下载您的文件 

在javascript中,您可以这样做

使用heroku api来显示页面

 < div id ="hidden" style ="display:none"></div>< script type ="text/javascript">$(document).ready(function(){//var text ='您的网址';$ .ajaxPrefilter(函数(选项){if(options.crossDomain&& jQuery.support.cors){var http =(window.location.protocol ==='http:'?'http:':'https:');options.url = http +'//cors-anywhere.herokuapp.com/'+ options.url;//options.url ="http://cors.corsproxy.io/url=" + options.url;}});$ .get('https://login.yahoo.com/',//就像yahoo功能(响应){var res =回应;$('#hidden').append(res);});}); 

将页面放置在隐藏的div中之后,您可以执行以下操作

  setTimeout(function(){$('#hidden').show();//或淡入淡出,css显示您想要的.},1000);}); 

I have created a download page that has a link to a file, I would like the file to download automatically after 10 seconds but am unsure of how to do this. The link to the file is stored in a cookie and is accessed on the download page and stored in a $file variable.

The link to the file will be similar to this:

https://cloud1.taccess.co.uk/cloud/uploads/eed376ad76d1f74b597aa2e21121f7e6tantami_cloud_file_580a40c1eff3af7484ef592c10bff10047b373cdc5dfd.pptx?AWSAccessKeyId=AKIAJ56YO6753B2RUT2Q&Expires=1477473886&Signature=mF6Zy1Mqo3HM5g%2B4cSePaXF9vM8%3D

This points to the file and includes the required permissions for the file to be downloaded. So in short, I am looking for a way for this link to be opened after 10 seconds so that the file can be downloaded.

Thanks

解决方案

your tag is php so i assume you want to add some dealy for download, i think this

will help you

     $filename = "your filename";
    header("content-type:application/any specific header"); // set the header
     // your content 

sleep(10)  // will add delay for 10 sec

header("Content-Disposition: attachment; filename=$file_name"); // will download your file

in javascript you could do like this

use heroku api to bring the page

<div id="hidden" style="display:none"></div>

  <script type="text/javascript">
$(document).ready(function(){
     // var text = 'your url';
      $.ajaxPrefilter( function (options) {
        if (options.crossDomain && jQuery.support.cors) {
          var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
          options.url = http + '//cors-anywhere.herokuapp.com/' + options.url;
          //options.url = "http://cors.corsproxy.io/url=" + options.url;
        }
      });

      $.get(
          'https://login.yahoo.com/',  // like yahoo
          function (response) {

          var res = response;
           $('#hidden').append(res);


      });

  });

after your page is placed inside hidden div then you could do something like this

setTimeout(function(){
   $('#hidden').show();// or fade, css display however you'd like.
}, 1000);
});

这篇关于10秒后下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆