downloading .gz file and SRV |
Site Admin
|
First it is not ZIP and therefore correct headers would be:
Content-Type: application/x-tar Content-Encoding: gzip in case of xxx.tar.gz or Content-Type: application/x-gzip in case of pure gz file also I'd highly recommend you not to use output buffer. It will make your server load much higher and won't help with anything. It's purpose is to output content by bigger chanks when you echo from php by very small ones. In your case passthrough is good enough. BTW, don't forget to CLOSE file handle!!! or just use readfile() instead. |
||||||||||||
_________________ The PHP IDE team |
|
Hi Dimitri, thank you for your reply.
Simply what you suggest doesn'work: as I mentioned, I tried all the possible configurations of Content-type (I paradoxally cannot download simple text/plain files, nor .doc, .pdf or .xls files): it seems to me something is going wrong on the behaviour of the server itself, since the download apparently starts but never suceeds. I just dont know what to do (a problem of system rights ?) and the example should be pretty simple to reproduce: does it work on your PC? I am using a winXP machine. Concerning the ob_*() functions: I well know that it is not recommended but they were put there just to distinguish the appereance of the two message windows on http client side. Whilst, for closing the handle, well the PHP manual does not mention that is mandatory to close it (you can see the help section for fpassthru() as they don't close the handle in their snippet): but thanks for the hint anyway, I'd better to close it. Can you pls confirm to me that you can reproduce this behaviour on XP? Does any other guy ever had my same problem? Thanks again Marco |
||||||||||||
|
Site Admin
|
Your code is broken
a) ob_ must be removed or with big files you'll easily exhause memory beyound memory limit or at least will load your life server too much. b) you need correct Content-Type header (not Content-type, not applixation/x-zip) c) it's recommended to use FULL file path and handle errors if file is not found or not opened. In case of error, you may want to issue Location: header to redirect browser to html with error message. Let know if after corrections it still does not work for you. |
||||||||||||
_________________ The PHP IDE team |
|
Hi dimitri,
ok for the mystype, but even with your suggestion I cannot move on. I have made 2 screenshots with the code just after the fpassthru() and after the exit of the script. (I cut out the ob_*() functions that were put only for sake of clarity for interaction between the creation of the output buffer and browser message boxes display). First screen shot You can see the breakpoint, the file exists and the filename is a full-length path. Also notice the first window for download in progress. Note that the ouput is correctly written (well something is written and I rely on the fact that is the correct gzip). Second screen shot Notice that the script as exited and the second error message box appears on the browser. All the code you see is the only code that is executed (no include/require). The <?php and ?> were omitted in the screenshot for saving space in the window. That's all, let me know. Thanks in advance Marco |
||||||||||||
|
Site Admin
|
I think you missed Content-Length header. It's a required header (see RFC 1945, p10.4)
|
||||||||||||
_________________ The PHP IDE team |
Site Admin
|
correct headers would be:
For further problems related to php and http, please consult with php manual and mentioned RFC. |
||||||||||||||
_________________ The PHP IDE team |
downloading .gz file and SRV |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by