You are here: Re: How do I send HTML and a file for 'Save-As' at the same time? « PHP Language « IT news, forums, messages
Re: How do I send HTML and a file for 'Save-As' at the same time?

Posted by Daedalus.OS on 05/29/05 06:41

Instead of refreshing to a static files, refresh to a php file that will
send back the file.

Lets say when the user click the link it brings him to some_page.php. In
this page you would put this code:

<META HTTP-EQUIV="refresh" content="1;
URL=http://yoursite.com/some/folder/file_gen.php">

file_gen.php should now generate the file and sent it back to be downloaded.
Without more detail about this generated file I can't tell you how exactly
to send it back. But here is a simple exemple that would return a
dynamically created javasctipt to be downloaded:

// The file is generated and its handler is contained by $file...
header('Content-type: application/javascript');
header("Content-length: ".filesize($file));
header('Content-Disposition: attachment; filename="destination_name.js"');
readfile($file);

You will find some more exemple in the user comments of the header() and
fread() manual pages:
http://ca3.php.net/manual/en/function.fread.php
http://ca3.php.net/header

Other function that might be useful:
http://ca3.php.net/manual/en/function.fwrite.php
http://ca3.php.net/manual/en/function.tempnam.php
http://ca3.php.net/manual/en/function.tmpfile.php

Dae

<edykstra@virtualcad.com> wrote in message
news:1117333937.281656.130930@g44g2000cwa.googlegroups.com...
> Hello,
>
> OK .. that makes sense. I didn't realize it was just waiting 5 seconds
> to serve me a file that already exists. I thought it was processing a
> file and serving it to me as soon as it was ready, which is what I need
> to do.
>
> The file I am going to serve the User can take anywhere from 3 to 30
> seconds to create dynamically. If I use a value too low, the page will
> refresh to 'Object not found'. If the value is too high, the User is
> waiting longer than they should have to.
>
> Here is what I want my application to do:
>
> 1. User clicks on a link.
> 2. Server sends HTML page explaining it may take up to 30 seconds.
> 3. Server sends file prompting a 'Save-As' as soon as it is ready.
>
> I would like it better if there was no User interaction other than step
> 1.
>
> Is this possible?
>
> Eric
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация