开发者

Create a Download Redirect page

I have a form where the user selects the images she wants to download, and then process_form.php does the dirty work of creating a zip file and putting the images that the user wanted into that zip file, and finally preparing the download, like this:

header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=images.zip");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");
readfile("images.zip"); 

The download happens as soon as the user hits the "开发者_StackOverflow社区Submit" button on the form.

I want to create a page that say something like:

Your download will begin automatically. If it doesn't, click here.

The advice I've gotten is make an "intermediate" page which would then trigger the download using javascript.

location.href='process_form.php'

Ok, Done. So, now, this new "intermediate" page creates a zip file and throws it on da serva, and displays "your download should bla bla bla", and javascript redirects to the process_form.php. BUT, all I see is a blank page, even through there is HTML in the "intermediate" page, after the closing } of the if(isset($_POST) bit of PHP.......So, why is my page blank?

Solution

Use HTML instead.

<meta http-equiv="refresh" content="5;url=process_ads.php"> 

That works.


From OP's own answer:

Solution

Use HTML instead.

<meta http-equiv="refresh" content="5;url=process_ads.php"> 

That works.


Try this

header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=images.zip");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");
readfile("images.zip");
header("refresh: 2; url=process_form.php"); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜