send file from CGI

D

detlef.reichl

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
 
D

dv

Detlef Reichl 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
 
D

detlef.reichl

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

Hi Detlef,
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.
 
M

Marcin Raczkowski

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

Hi Daniel

the zip file is not in the web root and also should not be
why not? securing data this way is kinda stupid.
afaik yes, but i also testet with other file types, with the same
result.
acording to http://www.iana.org/assignments/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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,631
Members
45,338
Latest member
41Pearline46

Latest Threads

Top