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

html at end of download - urgent please help!!

hi there

i have the following bit of code that downloads/uploads documents from
a sql database.

the problem i have is when i download an image for example and look at
it in notepad i see the binary data and below it the html from the page
the image was downloaded from. so my 10k image is now 32k.

please any help would be much appreciated.

thanks

shawn

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
Dim iLength As Integer =
CType(LifeFileUpload.PostedFile.InputStream.Length , Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String =
LifeFileUpload.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength)

'strip the path off the filename
i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = LifeFileUpload.PostedFile.FileName.Trim
Else
sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
End If

LifeFileUpload.PostedFile.InputStream.Read(bytCont ent, 0,
iLength)

objDonkey.SelectedClient.AddDocument(objDonkey.Use rName,
sFileName, sContentType, iLength, bytContent, "this is a test
document")
End Sub

Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetDoc.Click
Dim DocId As Integer
Dim objDoc As Life.Clients.Client.DocumentItem

DocId = HiddenSelectedDoc.Value
objDonkey.SelectedClient.GetDocuments()
objDoc = objDonkey.SelectedClient.DocumentList(DocId)
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()

Response.ContentType = "image/jpeg" 'objDoc.ContentType

Response.OutputStream.Write(CType(objDonkey.Select edClient.GetDocument(DocId),
Byte()), 0, CInt(objDoc.ContentLegnth))
Response.AddHeader("Content-Disposition",
"attachment;filename=" + objDoc.Filename)
Response.Flush()
End Sub

Nov 14 '06 #1
1 1085
Hi Shawn,

Try to clear the response object after the following code:

Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
// Clear the response object.
Response.Clear();

And then when you finished writing into the response stream:

Response.Flush();
Response.End();

I think it might help.

See ya.

Thiago Oliveira

sh**************@yahoo.com escreveu:
hi there

i have the following bit of code that downloads/uploads documents from
a sql database.

the problem i have is when i download an image for example and look at
it in notepad i see the binary data and below it the html from the page
the image was downloaded from. so my 10k image is now 32k.

please any help would be much appreciated.

thanks

shawn

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
Dim iLength As Integer =
CType(LifeFileUpload.PostedFile.InputStream.Length , Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String =
LifeFileUpload.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength)

'strip the path off the filename
i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = LifeFileUpload.PostedFile.FileName.Trim
Else
sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
End If

LifeFileUpload.PostedFile.InputStream.Read(bytCont ent, 0,
iLength)

objDonkey.SelectedClient.AddDocument(objDonkey.Use rName,
sFileName, sContentType, iLength, bytContent, "this is a test
document")
End Sub

Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetDoc.Click
Dim DocId As Integer
Dim objDoc As Life.Clients.Client.DocumentItem

DocId = HiddenSelectedDoc.Value
objDonkey.SelectedClient.GetDocuments()
objDoc = objDonkey.SelectedClient.DocumentList(DocId)
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()

Response.ContentType = "image/jpeg" 'objDoc.ContentType

Response.OutputStream.Write(CType(objDonkey.Select edClient.GetDocument(DocId),
Byte()), 0, CInt(objDoc.ContentLegnth))
Response.AddHeader("Content-Disposition",
"attachment;filename=" + objDoc.Filename)
Response.Flush()
End Sub
Nov 14 '06 #2

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

Similar topics

2
by: Edwinah63 | last post by:
Hi Everyone, All the very best for 2004!! i need urgent help with this problem, the users are about to skin me alive!! we have an access front end with linked to sql server 2k tables. ...
1
by: Jenny | last post by:
Need urgent help for an unsolved problem. In our ASP web application, we creat a Back button and if user click on this button, it execute history.go(-1) to go back to the previous page. All our...
8
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error for some of my web application users but not others??? Even though the application runs from a central webserver??? Thanks for...
6
by: varkey.mathew | last post by:
Dear all, Bear with me, a poor newbie(atleast in AD).. I have to authenticate a user ID and password for a user as a valid Active Directory user or not. I have created the IsAuthenticated...
7
by: zeyais | last post by:
Here is my HTML: <style> ..leftcolumn{float:left;width:300px;border: 1px solid #ccc} ..rtcolumn{float:left;width:600px;border: 1px solid #ccc} </style> <body> <div class="leftcolumn"...
0
by: bprasanth_20 | last post by:
Hi, I need an urgent help. I need to create a UDF (User Defined Function) in DB2 SQL which can accept any number of arguments (from 2 to 5 arguments). I do not how to achieve this. When I pass 2...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
2
by: ZEROFIVE | last post by:
If i have made a .zip file(s) present on a webpage for other visitors to download them, what do i use? <a href="filename.zip" download="true">zip file</a> ? Thanks again, Jimmy
3
by: coopst1 | last post by:
below is my almost completed code. I need help trying to figure out how to display to a textarea all the data I have in phpMyAdmin (database). I have two methods near the bottom called itemResults()...
0
by: Christopher | last post by:
Urgent Help Needed: The EPVH-1.1 Visual Hull Library. Dear All, I am a student doing research in computer vision. The EPVH-1.1 Visual Hull Library will really help a lot in my research. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.