473,287 Members | 1,946 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,287 software developers and data experts.

Sending Zip file from Database problems

I'm trying to get an ASP to return a zip file to the remote browser from an
Image (BLOB) field in SQL Server 2000 but Internet Explorer keeps saying:

Cannot open C:\Documents and Settings\Frostillicus\Local Settings\Temporary
Internet Files\Content.IE5\U7GXENGF\file[1].zip

The URL to open the zip file is like this: doc_view.asp?id=1&ver=2

....where id and ver represent the zip file's version in the database. The
code I've pieced together to return the zip file is as follows (note: this
code works fine for PDF, JPG, DOC, XLS, GIF, and all sorts of files - just
not zip - HOWEVER, if I click "save" instead of "open" in the download box
then open the zip file manually, it works fine - Internet Explorer just
won't load WinZip for me automatically)

<% @language="VBScript" %>
<!-- #include file="./include/adovbs.inc" -->
<%
Response.Buffer = True
Response.Clear

Set RS = Server.CreateObject("ADODB.Recordset")

SQL = "SELECT ContentTypeString, DocumentData, DocumentTitle, FileExtension,
DocumentContentLength FROM DocumentVersion "
SQL = SQL & "WHERE (DocumentID = " & id & ") AND (VersionNumber = " & ver &
")"

Set RS = DbConn.Execute(SQL)

If Not RS.EOF Then
Response.ContentType = RS(0)

' zip file needs to be 1 byte more for some silly reason
If Not RS(0) <> "application/zip" Or Not RS(0) <>
"application/x-zip-compressed" Then
Response.AddHeader "Content-Length", RS(4) + 1
Else
Response.AddHeader "Content-Length", RS(4)
End If

Response.AddHeader "Content-Disposition", "filename=" & RS(2) & "." &
RS(3)
Response.BinaryWrite RS(1)

If Not RS(0) <> "application/zip" Or Not RS(0) <>
"application/x-zip-compressed" Then
Response.Write vbCrLf
End If
End If

RS.Close
Set RS = Nothing
Response.Flush
%>

The conscientious among us might say "what's the extra vbCrLf being printed
for, then"? Well, without the final carriage return I get a corrupt zip file
that is at least capable of being repaired. I have no idea why I need the
last carriage return but I decided to stick it in there after I saw (using
HTTP Watch to spy on the headers received) that the same zip file downloaded
via a normal hyperlink was one byte larger than the same zip file being
served up from the database (the binary data saved to the database is the
same length as the content-length for the normal hyperlinked zip file). So,
when I get the download-file box in Internet Explorer, if I click "Save"
then open the zip file manually, it works just fine.

If I click "Open", I get the nasty error message mentioned at the beginning
of this prolix post :-( I am tearing my hair out because this sort of thing
just ain't supposed to be this god-damned difficult. I mean, it's just a
stream of binary data and I'm sending the correct content types. What is so
special about Zip files?
Jul 19 '05 #1
2 2287
By the way, I've tried clearing my cache, rebooting, etc. I even browsed to
the directory where IE is trying to save the file using a command-prompt,
and the directory does actually exist, and there are copies of other files I
have downloaded using this save "doc_view.asp" file, but the zip file just
ain't there.

I also tried sending the "application/octet-stream" content-type, no luck.
Jul 19 '05 #2
Frostillicus wrote:
I'm trying to get an ASP to return a zip file to the remote browser
from an Image (BLOB) field in SQL Server 2000 but Internet Explorer
keeps saying:

Cannot open C:\Documents and Settings\Frostillicus\Local
Settings\Temporary Internet Files\Content.IE5\U7GXENGF\file[1].zip

The URL to open the zip file is like this: doc_view.asp?id=1&ver=2

...where id and ver represent the zip file's version in the database.
The code I've pieced together to return the zip file is as follows
(note: this code works fine for PDF, JPG, DOC, XLS, GIF, and all
sorts of files - just not zip - HOWEVER, if I click "save" instead of
"open" in the download box then open the zip file manually, it works
fine - Internet Explorer just won't load WinZip for me automatically)


My guess: Mozilla and Opera do not display this error, and the ASP script
(a) sits behind NTLM authentication, or (b) depends on cookies (directly or
for session variables).

See the notes on these articles:
http://support.microsoft.com/?id=264143
http://support.microsoft.com/?id=185978

It appears that IE sometimes "loses" request information when handing the
response off to helper apps:

"Internet Explorer can sometimes lose information pertinent to a
particular download for an Active Document server (Word, Excel.)
When this occurs, Internet Explorer is able to activate the Active
Document server but when the server attempts to bind to and read
the data for the document, Internet Explorer re-downloads the
document from the context of the server.

When the server is an out-of-process local server, the second
download is treated as a new session with the Web server."
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #3

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

Similar topics

1
by: Stephajn Craig | last post by:
It's been a while since I posted here, but here goes. Our server is a Windows 2000 Server with Service Pack 3, IIS 5 with Lockdown Wizard applied. My first problem is related to...
0
by: Walt | last post by:
I'm running SQL Server 2000 SP2 transactional replication. Periodically replication fails due to primary key errors. On investigation I find that the offending transaction is attempting to insert...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
0
by: Buddy Ackerman | last post by:
I'm sending file to the client (see sample code below) but when I send a large file the user gets a document contains no data message. response.contenttype = "application/x-unknown" myheader =...
0
by: Buddy Ackerman | last post by:
I'm sending file to the client (see sample code below) but when I send a large file the user gets a document contains no data message. response.contenttype = "application/x-unknown" myheader =...
4
by: Drygast | last post by:
I have a form that updates an accessdatabase, when I close the form I have put a question wheter to send the database to the intenet or not. Is it possible to automatically check if the database...
0
by: Lee | last post by:
Hi, I am trying to send and receive a file (it is actually an xml file, however any file may possibly be sent) using;- sending ..... public void send() {
9
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.