下载后如何重定向到另一个页面 [英] How To Redirect To Another Page After Download

查看:76
本文介绍了下载后如何重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!



我正在开发一个网页,该网页将在访问时开始下载文件过程。



然后会自动重定向到另一页。



我尝试过使用下面的代码,但它不起作用。它只会在没有下载文件的情况下重定向到另一个页面。



请问有谁知道更好的方法来实现这两个目标吗?



请回复,thnaks。



 <?  php   

/ * 重定向 浏览器 * /

标题(位置: http://www.google.com/);

/ * 生成 确定 代码 < span class =code-summarycomment> get 执行 我们 重定向。 * /

exit;

>

< !DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN http://www.w3.org/TR/xhtml1/DTD /xhtml1-transitional.dtd\">
< html xmlns = http://www.w3.org/1999/xhtml >
< head >
< meta http-equiv = Content-Ty pe content = text / html; charset = utf-8 / > ;
< meta 名称 = keywords content = rhapsody of relaities,daily,daily devotional,Christ Embassy,移动下载,电子书阅读器,ios,android,devotional,christian,福音,牧师克里斯,牧师,克里斯,免费下载,频道,电视,牧师克里斯教学,奇迹气氛,特殊视频,信仰说 / >
< title > 您好!< / title >
< link < span class =code-attribute> rel = stylesheet 类型 = text / css href = css / style.css >

< / head >

< body >
< span class =code-summarycomment><? php
< span class =code-summarycomment>
$ file =' July-2013.pdf' ;



if < span class =code-summarycomment>(file_exists($ file)) { < span class =code-summarycomment>

< span class =code-summarycomment> header('Content-Description: 文件 转移');

header('Content-Type: application / octet-stream ');

header('Content-Disposition: 附件; filename =' .basename($ file));
header('
Content-Transfer-Encoding: binary');

< span class =code-summarycomment> header('Expires: 0' );

header('Cache-Control: must-reval idate');

header('Pragma: public');

header('Content-Length: ' files ize($ file));

ob_clean();

< span class =code-summarycomment> flush();
< span class =code-summarycomment>
readfile($ file);

exit;

}

>

解决方案

file =' July-2013.pdf' ;



if ( file_exists(


file)) { < span class =code-summarycomment>

< span class =code-summarycomment> header('Content-Description: 文件 转移');

header('Content-Type: application / octet-stream');

header('Content-Disposition: 附件; filename =' .basename(


file));
header(' Content-Transfer-Encoding: binary');

< span class =code-summarycomment> header('Expires: 0' );

header('Cache-Control: must-reval idate');

header('Pragma: public');

header('Content-Length: ' files IZE(

Hello!

I'm developing a webpage that will commence a download file process when visited.

Then will automatically redirect to another page.

I've tried using the following code below, but it doesn't work. It only redirects to another page without downloading the file.

Please does anyone know a better way to accomplish both?

Kindly respond, thnaks.

<?php

/* Redirect browser */

header("Location: http://www.google.com/");

/* Make sure that code below does not get executed when we redirect. */

exit;

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="rhapsody of relaities, daily, daily devotional, Christ Embassy, mobile downloads, ebook readers, ios, android, devotional, christian, gospel, pastor chris,pastor, chris, free download, Channel, TV, pastor chris teaching, atmosphere for miracles, special videos, faith speaks"/>
<title>Hello!</title>
<link rel="stylesheet" type="text/css" href="css/style.css">

</head>

<body>
<?php

$file = 'July-2013.pdf';



if (file_exists($file)) {

    header('Content-Description: File Transfer');

    header('Content-Type: application/octet-stream');

    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');

    header('Expires: 0');

    header('Cache-Control: must-revalidate');

    header('Pragma: public');

    header('Content-Length: ' . filesize($file));

    ob_clean();

    flush();

    readfile($file);

    exit;

}

?>

解决方案

file = 'July-2013.pdf'; if (file_exists(


file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename(


file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize(


这篇关于下载后如何重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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