Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.BinaryWrite Issue

Status
Not open for further replies.

bnhcomputing

IS-IT--Management
Jul 29, 2002
21
US
<%@ Language=VBScript %>
<%
Response.Buffer=true
Response.clear
set st = server.CreateObject (adodb.strem")
Response.ContentType = "application/unknown"
Response.Addheader "ContentType", "application/unknown"
Response.Addheader "Content-Disposition", "inline; filename=test.doc"
st.open
st.Type=1
st.LoadFromFile "test.doc"
Response.BinaryWrite st.read
st.close
Response.End
%>

The source file is a good doc file. The file I get if I select save is twice(2) as big, and full of junk.

I used unknown application because I need it generic enought to work with any/all filetypes.

Any ideas?

Thanks in advance

-----
bnhcomputing
 
You are better off storing the content type of the file in another field of your table and using that to set the contenttype when you pull the file down for display.

What happens if you set the contenttype specifically to Word?

Paranoid? ME?? WHO WANTS TO KNOW????
 
Same result, regardless what content type I use. Additionaly, what content type would you have for say (Autocad, paradox, word perfect, dll, tubo tax .tax files) these are just a few, there are thousands out there.

--
bnhcomputing
 
There were a couple of typos in your code but this worked when I tried it.

Code:
<%@ Language=VBScript %>
<% 
Response.Buffer=true
Response.clear
set st = server.CreateObject ("adodb.stream")
Response.ContentType = "application/unknown"
Response.Addheader "ContentType", "application/unknown"
Response.Addheader "Content-Disposition", "inline; filename=test.doc"
st.open
st.Type=1
st.LoadFromFile "\\server\folder\test.doc"
Response.BinaryWrite st.read
st.close
Response.End
%>

It would NOT load the doc file from a relative path for me I had to put a full path to the file for it to work.

Paranoid? ME?? WHO WANTS TO KNOW????
 
THANKS, the typos were the problem. Now that I got that working, I was hoping I could avoid the need to right the file altogether.

<---Code----->
cn.Open application("dataconn")
rs.Open "SELECT TOP 1 DocID, Doc_IMG, DocumentName FROM documents",cn,2,3
mydocument = rs("DocumentName")
myBuffer = rs("Doc_IMG")
st.open
st.Type=1
st.write myBuffer
<---------->

I get an error on the st.write myBuffer line.
I also tried:
st.write rs("Doc_IMG")
AND
st.write rs(1)
all three lines give me the same error

<--Error-->
ADODB.Stream error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
<--------->
The Doc_IMG field is a "text" field. I store the actual file in the SQL table.

Any ideas, or typos I didn't see?

thanks in advance

---
bnhcomputing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top