RE: Header problem

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

 



Unless I am missing something, your page has too many if and it always ends up with print something ... but there is no exit after the download, so the zip will have extra output included without a reason ... which is an error, imho, dunno how else explain if you can't see your print "links" at the end of the page ... 

Regards

> Date: Sun, 4 Oct 2009 19:09:35 +0200
> From: php.net@xxxxxxx
> To: php-general@xxxxxxxxxxxxx
> Subject: Re:  Header problem
> 
> Hello Andrea
> 
> Andrea Giammarchi wrote on 2009-10-04 18:49:
> > 
> >  > Header must come first (before you output anything) or you get a parse
> >  > error
> > 
> > I try to better explain ...
> > 
> > HTTP works like this: you ask something, you receive something, html and 
> > texts are just one option.
> 
> Got it so far
> 
> > Your example page mess up html, zip, everything, because when you 
> > download a file you still have the rest of the page sent in the output.
> 
> Nops, not really.
> 
> index.php:
> print stuff
> do stuff
> open download.php in a _new_ window.
> print more stuff
> page end
> 
> this should be possible, right? Two different headers for two different 
> pages.
> 
> > A download should have ONLY file related info/headers and nothing else 
> > in the output ... echo/print in the middle of the code before an header 
> > is an error, everything in output before an header is an error, 
> > everything after headers that is not related to that header is an error, 
> > got my point?
> 
> Jep! And that's actually what I do. What I could, is to add exit; after 
> the headers have been sent and the file have been pushed. I do an update 
> of the database to tell the system that the files in the zipfile has 
> been downloaded.
> 
> > To decide how a page should behave, you must be able to do not produce 
> > anything except the expected output with expected headers, that's why I 
> > have said headers are fundamental for a response, we cannot play with 
> > outputs however we want.
> 
> The only output is the headers of the zipfile:
> 
>    header('Accept-Ranges: bytes');
>    header("Content-Type: application/zip");
>    header("Content-Length: $size");
>    header("Content-disposition: attachment; 
> filename=\"".basename($zip_filename)."\"");
>    header("Content-Transfer-Encoding: binary");
> readfile($filename);
> 
>    // we need to reload top5 to have a current view
>    unset($_SESSION['top5']);
>    $_SESSION['reload_top5'] = 1;
> 
>    // NOTE second param shall be an array, not a variable when 
> downloading zip files
>    download_completed($member_id, $downloaded_version_ids);
> 
> Wouldn't you say this is okay?
> 
> > As summary, once you have created and tried a dedicated page without a 
> > single white space or print before, during, or after the dedicated 
> > download stuff, I'll try to understand where is the error.
> > Otherwise it could be everything, and I am against "magic behaviors" ... 
> > you need to download? Well, create a file which aims id to download and 
> > nothing else, or you gonna constantly find these kind of problems in 
> > your applications.
> 
> I believe the testpage does forfill that request? Or do you mean otherwise?
> 
> Kind regards
> Kim
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
 		 	   		  
_________________________________________________________________
Windows Live Hotmail: Your friends can get your Facebook updates, right from Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

[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