Send file from CGI

Hi,

in a webapplication, a user can select from some options. Depending on
the selection some files are packed together in a zip file and get send
to the user. So far it works perfect, but the zip file is not recognized
from the browser and it displays the data as garbage.

The code that sends the data:

print @cgi.header(“type” => “application/zip”)
print @cgi.header(“length” => File.size(zipfile).to_s)

file = File.new(zipfile, “r” )
while true
begin
data = file.sysread(65536)
rescue EOFError
break
else
@cgi.print data
end
end

Any suggestions?

Cheers
detlef

Detlef R. schrieb:

Hi Detlef,

Any suggestions?

Wouldn’t be easier to redirect the clients browser to the zip file? In
addition is “application/zip” the correct mime type?

HTH,

Daniel

Am Montag, den 05.11.2007, 01:34 +0900 schrieb Daniel Völkerts:

Detlef R. schrieb:

Hi Detlef,

Any suggestions?

Wouldn’t be easier to redirect the clients browser to the zip file?

Hi Daniel

the zip file is not in the web root and also should not be

In
addition is “application/zip” the correct mime type?

afaik yes, but i also testet with other file types, with the same
result.

Detlef R. wrote:

the zip file is not in the web root and also should not be

why not? securing data this way is kinda stupid.

In
addition is “application/zip” the correct mime type?

afaik yes, but i also testet with other file types, with the same
result.

acording to Media Types it’s.

but some shity browsers (read IE wants file to have .zip extension even
if it’s something like bleh.html?file=bloh.zip)