Re: send a file or stream

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok it works, but it returns me the same .php file, not the one I am creating



On 8/29/06, Peter Lauri <lists@xxxxxxxxxxx> 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:moraloco@xxxxxxxxx]
Sent: Wednesday, August 30, 2006 10:25 AM
To: Peter Lauri
Cc: php-general@xxxxxxxxxxxxx
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 <lists@xxxxxxxxxxx> 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:moraloco@xxxxxxxxx]
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 <lists@xxxxxxxxxxx> 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:moraloco@xxxxxxxxx]
Sent: Wednesday, August 30, 2006 2:34 AM
To: php-general@xxxxxxxxxxxxx
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










[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux