I think the stations.zip is empty... Try this:

Between your scripting and the readfile() put a sleep(2); between so it waits 2 
seconds before pushing the data.

And I also suggest:

while()
{
fwrite($da, "$somevar1:$somevar2");
}
fclose($da);

Header()....

(try sleep(2); here)

readfile();


-----Original Message-----
From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 31, 2006 1:25 AM
To: Peter Lauri
Cc: php-general
Subject: Re: [PHP] send a file or stream

I can download it, but when I see the file I downloaded has 0 bytes, and I
have readfile("stations.zip");




On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> But can you download it correctly? Is it just the download box that shows
> 0 bytes?
>
> Or is it so that you actually is doing what you do below readfile()
> without any argument? So that you are actually downloading something empty?
> :)
>
> /Peter
>
>
>
> -----Original Message-----
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 8:00 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] send a file or stream
>
> Hi!!
>
> Well it works now, but with another issue, when I download it, it says
> that
> it size is 0 bytes!!
>
> i fwrite the file in a while, is it correct?
>
> header()...
> while()
> {
> fwrite($da, "$somevar1:$somevar2");
> }
> fclose($da);
>
> readfile();
>
> thanks
>
>
>
> On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > Try this:
> >
> > header("Pragma: public");
> > header("Expires: 0"); // set expiration time
> > header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> > header("Content-Type: application/octet-stream");
> > header('Content-Disposition: attachment; filename="stations.gzip"');
> > header("Content-Transfer-Encoding: binary");
> > header("Content-Length: ".filesize(stations.gzip));
> > readfile("stations.gzip");
> >
> > /Peter
> >
> > PS! To maintain the list and its functionality, do not post same message
> > multiple times  DS!
> >
> >
> > -----Original Message-----
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 11:01 AM
> > To: Peter Lauri
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] send a file or stream
> >
> > Ok it works, but it returns me the same .php file, not the one I am
> > creating
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> > >
> > > You need to make sure that you are not outputting ANYTHING before you
> do
> > > this. I might guess that you have a whitespace in the top of the
> script.
> > As
> > > soon as you output, the server can not send any more header
> information,
> > and
> > > the browser will think it is just text instead of treating it as an
> > > octet-stream.
> > >
> > >
> > >
> > > /Peter
> > >
> > >
> > >
> > > _____
> > >
> > > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, August 30, 2006 10:25 AM
> > > To: Peter Lauri
> > > Cc: php-general@lists.php.net
> > > Subject: Re: [PHP] send a file or stream
> > >
> > >
> > >
> > > I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
> > > ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
> > >
> > >
> > >
> > > <?php
> > > $params = array('level' => 6, 'window' => 15, 'memory' => 9);
> > >
> > > $texto_original = "This is a test.\nThis is only a test.\nThis is not
> an
> > > important string.\n";
> > > //echo "El texto original tiene " . strlen($texto_original) . "
> > > caracteres.\n";
> > >
> > > $da = fopen('stations.gzip', 'w');
> > > stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE,
> $params);
> > > fwrite($da, $texto_original);
> > > fclose($da);
> > >
> > > header("Content-Type: application/octet-stream");
> > > readfile("stations.gzip");
> > >
> > >
> > >
> > >
> > >
> > > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> > >
> > > <?php
> > > header("Content-Type: application/octet-stream");
> > > readfile("path_to_compressed_file");
> > > ?>
> > >
> > >
> > >
> > > Should do it then. if you know the path to the file :)
> > >
> > >
> > >
> > > _____
> > >
> > > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, August 30, 2006 10:10 AM
> > > To: Peter Lauri
> > > Subject: Re: [PHP] send a file or stream
> > >
> > >
> > >
> > > 1. A user sends a request to your server to get a compressed file
> > > 2. You compress the file on the server
> > > 3. I want to send back the file to the user
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> > >
> > > Do you mean the following:
> > >
> > > 1. A user sends a request to your server to get a compressed file
> > > 2. You compress the file on the server
> > > 3. You want to send back to compressed file to the server
> > >
> > > It is number 3 you asking for?
> > >
> > > In that case:
> > >
> > > <?php
> > > header("Content-Type: application/octet-stream");
> > > readfile("path_to_compressed_file");
> > > ?>
> > >
> > > /Peter
> > >
> > >
> > > -----Original Message-----
> > > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, August 30, 2006 2:34 AM
> > > To: php-general@lists.php.net
> > > Subject: [PHP] send a file or stream
> > >
> > > Hi!
> > >
> > > i want to send a file or output stream in a .php, but first compress
> it,
> > I
> > > tryed the example to compress files but how do i do to send as answer
> to
> > > the
> > >
> > > http request??
> > >
> > > Rafa
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to