karenros
12-15-2008, 11:31 AM
I am trying to save a file in my webserver and i am using xmlhttp but nothing saves in the directory that i have specified..
Here is my code
Function Sendit(sFilename, sType)
'sFilename = Mid(sFilename, InStrRev(sFilename, "\") + 1, Len(sFilename))
sdata = getFileBytes(sFilename, sType)
'MsgBox (sData)
sFilename = Mid(sFilename, InStrRev(sFilename, "\") + 1, Len(sFilename))
Dim xmlhttp
Set xmlhttp = CreateObject("MSXML2.XMLHTTP.3.0")
strUrl = "http://localhost/asc/Images/" & sFilename
xmlhttp.Open "PUT", strUrl, False
xmlhttp.Send sdata
xmlhttp.Status
xmlhttp.Response
Set xmlhttp = Nothing
MsgBox ("Done!! File Uploaded Successfully.")
End Function
Function getFileBytes(flnm, sType)
Dim objStream
Set objStream = CreateObject("ADODB.Stream")
If sType = "on" Then
objStream.Type = 1 ' adTypeBinary
Else
objStream.Type = 2 ' adTypeText
objStream.Charset = "ascii"
End If
objStream.Open
objStream.LoadFromFile flnm
If sType = "on" Then
getFileBytes = objStream.Read
Else
getFileBytes = objStream.ReadText
End If
objStream.Close
Set objStream = Nothing
End Function
any help will be appreciated..
Thanks,
Karen
Here is my code
Function Sendit(sFilename, sType)
'sFilename = Mid(sFilename, InStrRev(sFilename, "\") + 1, Len(sFilename))
sdata = getFileBytes(sFilename, sType)
'MsgBox (sData)
sFilename = Mid(sFilename, InStrRev(sFilename, "\") + 1, Len(sFilename))
Dim xmlhttp
Set xmlhttp = CreateObject("MSXML2.XMLHTTP.3.0")
strUrl = "http://localhost/asc/Images/" & sFilename
xmlhttp.Open "PUT", strUrl, False
xmlhttp.Send sdata
xmlhttp.Status
xmlhttp.Response
Set xmlhttp = Nothing
MsgBox ("Done!! File Uploaded Successfully.")
End Function
Function getFileBytes(flnm, sType)
Dim objStream
Set objStream = CreateObject("ADODB.Stream")
If sType = "on" Then
objStream.Type = 1 ' adTypeBinary
Else
objStream.Type = 2 ' adTypeText
objStream.Charset = "ascii"
End If
objStream.Open
objStream.LoadFromFile flnm
If sType = "on" Then
getFileBytes = objStream.Read
Else
getFileBytes = objStream.ReadText
End If
objStream.Close
Set objStream = Nothing
End Function
any help will be appreciated..
Thanks,
Karen