DownloadFile Function in COM
Hi all,
This is my 1st ever posting, please shout at me if anything I did wrong.
I am writing a Component similar to aspSmartUpload about uploading and downloading files. I am using VB6.
I need some direction about the downloadfile function. Basically it will prompt a Open/Save dialog, then open or save using the common dialog controls.
It's trival using asp, http://support.microsoft.com/kb/q260519/
Thanks.
Re: DownloadFile Function in COM
pleaszzzzzzzzzz, anyone help me?
I started with Upload function and made it working, but now I am pulling my hair to figure out downloadfile function.
Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
Public Sub DownloadFile(ByVal URL As String)
DoFileDownload StrConv(URL, vbUnicode)
End Sub
It's working when I create standard EXE, but when I create a dll and call in asp, it's not working, but there is no error!
Pleasezzzzzzzz help!!!
Re: DownloadFile Function in COM
I wish to remove this thread, I am :afrog:
On 2nd thought, I still want to get help about something interesting:
The code inside my dll is working.
Public Sub DownloadFile(ByVal strFileFullName As String, Optional ByVal strContentType As String, Optional ByVal strNewFileName As String)
'/***************************************************************************************************\
' Download() *
' Purpose: Download file into a specified virtual or physical path *
' Inputs: SourceFile is the source file. The path can be a virtual or a physical path. *
' Optional ContentType and NewFileName indicates a new name in the "Save As" dialog box. *
' *
'\************************************************************************************************** */
Dim strFileName As String
strFileName = GetFileName(strFileFullName)
If strFileName = "" Then
m_objResponse.Write "Filename Not specified."
m_objResponse.End
End If
'Start the download process if all is good
m_objResponse.Clear
'response.contentType = "application/mdb"
m_objResponse.AddHeader "content-disposition", "attachment; filename=" & strFileName
'use stream to write file
Dim adoStream As Object
Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open
adoStream.Type = 1
adoStream.LoadFromFile (strFileFullName)
m_objResponse.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing
m_objResponse.End
End Sub
But if I use same code in asp as the following:
<%
Response.ContentType = "application/x-unknown" ' arbitrary
fn = "BigError.mdb"
FPath = "c:\temp" & fn
Response.AddHeader "Content-Disposition","attachment; filename=" & fn
Response.end
Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(FPath)
Response.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing
%>
It's not working, I can not write into the file, the file size always show zero. Also I found that if I dont use Response.end, I will get error indicated in http://support.microsoft.com/kb/303750 even in IE7.
So frustrated even I made it working.... :mad:
Re: DownloadFile Function in COM
[QUOTE=RedButton] Response.end
[QUOTE]
This should be Response.Buffer, then will work fine. :bigyello: