473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Serving ZIP files to IE using PHP

Hi,
I've been wrestling for several months now with this issue in IE:
http://support.microsoft.com/?kbid=308090

(IE thinks that ZIPs sent from a script are corrupt when they are not).
IE now also seems to think that many other files are ActiveX controls
and pops up the "Some files may damage your computer...Open Save
Cancel" dialog.

However, I am quite certain that others have managed to use a script
serve ZIPs, PPTs or PDF files to clients using IE, as I saw download.com
do just that a moment ago.

I am currently using IIS and a Windows-ized version of mod_rewrite to do
URL rewriting so that IE in theory should not know that it is receiving
a ZIP file from script. Nonetheless, the error occurs even with
rewriting invoked. The problem seems to be that after IE pops up its
security dialog, it does not issue another HTTP request, but seems to
expect to go get the file.

Can anyone give me advice on how to do this? A tutorial, a newsgroup
thread, anything would be useful...

Thanks,

Eric
Jul 17 '05 #1
6 2338
On Wed, 31 Mar 2004 12:12:08 -0500, Eric Ellsworth wrote:
However, I am quite certain that others have managed to use a script
serve ZIPs, PPTs or PDF files to clients using IE, as I saw download.com
do just that a moment ago.

Eric..

I coded this function a long time ago that works without issue with ZIP
files (just tried it with IE6 too):
function download($file) {
if (empty($file) || !@file_exists($file)) return false;

@header('Content-type: archive/tar');
@header('Content-length: ' . @filesize($file));
@header('Content-disposition: attachment; filename=' .
array_pop(split('/', $file)));
@header('Content-transfer-encoding: binary'); @readfile($file);

return true;
}
$file in this case is a complete path name hence the array_pop() and
split() calls to retrieve just the filename to send as the file to be
saved.

Hope this is at least of some help to you =)

Regards,

Ian
[XP trimmed (php.lang not available on my news server)]

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #2
On 03/31/2004 02:12 PM, Eric Ellsworth wrote:
I've been wrestling for several months now with this issue in IE:
http://support.microsoft.com/?kbid=308090

(IE thinks that ZIPs sent from a script are corrupt when they are not).
IE now also seems to think that many other files are ActiveX controls
and pops up the "Some files may damage your computer...Open Save Cancel"
dialog.

However, I am quite certain that others have managed to use a script
serve ZIPs, PPTs or PDF files to clients using IE, as I saw download.com
do just that a moment ago.

I am currently using IIS and a Windows-ized version of mod_rewrite to do
URL rewriting so that IE in theory should not know that it is receiving
a ZIP file from script. Nonetheless, the error occurs even with
rewriting invoked. The problem seems to be that after IE pops up its
security dialog, it does not issue another HTTP request, but seems to
expect to go get the file.

Can anyone give me advice on how to do this? A tutorial, a newsgroup
thread, anything would be useful...


There is nothing that can be done except for telling the user to save
the file and open it later.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #3
Hi Ian,
Thanks for the quick reply - I will try using your code. Do you mind
if I ask why you used the @'s in front of the header function?

Thanks,

Eric

Ian.H wrote:
On Wed, 31 Mar 2004 12:12:08 -0500, Eric Ellsworth wrote:

However, I am quite certain that others have managed to use a script
serve ZIPs, PPTs or PDF files to clients using IE, as I saw download.com
do just that a moment ago.


Eric..

I coded this function a long time ago that works without issue with ZIP
files (just tried it with IE6 too):
function download($file) {
if (empty($file) || !@file_exists($file)) return false;

@header('Content-type: archive/tar');
@header('Content-length: ' . @filesize($file));
@header('Content-disposition: attachment; filename=' .
array_pop(split('/', $file)));
@header('Content-transfer-encoding: binary'); @readfile($file);

return true;
}
$file in this case is a complete path name hence the array_pop() and
split() calls to retrieve just the filename to send as the file to be
saved.

Hope this is at least of some help to you =)

Regards,

Ian
[XP trimmed (php.lang not available on my news server)]

Jul 17 '05 #4
[ Thread rearranged into chronological order ]
Ian.H wrote:

[ snip ]
function download($file) {
if (empty($file) || !@file_exists($file)) return false;

@header('Content-type: archive/tar');
@header('Content-length: ' . @filesize($file));
@header('Content-disposition: attachment; filename=' .
array_pop(split('/', $file)));
@header('Content-transfer-encoding: binary'); @readfile($file);

return true;
}

[ snip ]
On Mon, 05 Apr 2004 16:22:52 -0400, Eric Ellsworth wrote:
Hi Ian,
Thanks for the quick reply - I will try using your code. Do you mind
if I ask why you used the @'s in front of the header function?

Thanks,

No probs at all.. hope it helps you =)

The @ char before a function in PHP supresses any errors/ warnings that
function may produce.

We're not looking for browser output here and I don't need the error
checking in the function (the way I used/ coded it anyway) as this is done
separately.. so to keep PHP quiet just incase.. I supressed the output.

For the actual checking.. I'd do something like:
<?php
[...]

if (is_readable($file)) {
download($file);
} else {
/* Throw some kind of error about problem reading file... */
}

[...]
?>
or something along those lines. The reason the "validation" was done
outside of the function as it was part of a much larger script and had
other considerations I needed to take into consideration etc =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #5
Eric Ellsworth wrote:
Hi,
I've been wrestling for several months now with this issue in IE:
http://support.microsoft.com/?kbid=308090

(IE thinks that ZIPs sent from a script are corrupt when they are not).
IE now also seems to think that many other files are ActiveX controls
and pops up the "Some files may damage your computer...Open Save
Cancel" dialog.

However, I am quite certain that others have managed to use a script
serve ZIPs, PPTs or PDF files to clients using IE, as I saw download.com
do just that a moment ago.

I am currently using IIS and a Windows-ized version of mod_rewrite to do
URL rewriting so that IE in theory should not know that it is receiving
a ZIP file from script. Nonetheless, the error occurs even with
rewriting invoked. The problem seems to be that after IE pops up its
security dialog, it does not issue another HTTP request, but seems to
expect to go get the file.

Can anyone give me advice on how to do this? A tutorial, a newsgroup
thread, anything would be useful...

Thanks,

Eric

Exactly what code have you tried?
If this isn't what you did, you could sent a content-type header telling the
browser you are sending a ZIP file, or maybe try the content-type
application/octet-stream
Jul 17 '05 #6
> Do you mind if I ask why you used the @'s in front of the header function?

So that it doesn't "complain" if the headers were already sent (aka
not output php's error text).
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alan | last post by:
I have a website with no ssi, php, cgi...nothing. Plain old flat pages are all it serves. I need to upload a list to it - a big, plain text list in html. A 2Mb list! With gzip compress, it comes...
0
by: jack | last post by:
I am getting this error on my web server runnint ASP.NET on Windows 2003, it kills the serving web pages. The only way to get the web pages to start serving is to restart the server. I can't find...
21
by: Nicholas Sherlock | last post by:
Hey all, People on my website register to be allowed access to certain downloads. I store these files above the document root so that they can't be accessed by Apache (Only from PHP). I wrote a...
3
by: Prash | last post by:
IIS serving javascript files, gives me error 4/21/2006 6:48 AM Guys/Gals, I am using IIS as a server to serve the javascript files. But it is giving me the error as "Object doesn't support this...
1
by: Ben | last post by:
Hi there, Perhaps someone can help me. For some reason, when my Python script runs and loads an HTML page in a new browser window at the local host (desktop), the links to my stylesheet and all...
2
by: David T. Ashley | last post by:
I've used Apache with the automatic directory indexes ... works great ... just click on the file name and IE magically figures out how to display it .... if it is a .PDF then Adobe Acrobat runs,...
12
by: -Lost | last post by:
In Firefox and Safari for example, if I serve my XHTML documents as application/xml or xhtml+xml they only display the top inch or so of the document. In Opera it says "object has been blocked."...
3
by: Sander Tekelenburg | last post by:
Situation: I store news articles as individual PHP files. Each file contains HTML and now and then some embedded PHP snippets. Serving those news articles on the Web works fine, through...
2
by: AeonOfTime | last post by:
Hi everyone, I am working on a project where I have .wmv files stored outside of the server's www root, and want to serve them via a custom web interface. It's all on windows, and is only...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.