PDA

View Full Version : File doesnt save when i use xmlhttp



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

Bob Phillips
12-15-2008, 01:00 PM
Cross-posted at MrExcel http://www.mrexcel.com/forum/showthread.php?t=359320

CreganTur
12-15-2008, 02:00 PM
Hey Karen,

please read this article (http://www.excelguru.ca/node/7) on cross-posting. Cross-posting isn't a horrible sin or anything; this will just teach you good cross-posting habits, like including links to the cross-post so that others can check and see if an answer has been provided elsewhere before they try to answer your problem.

Thanks :thumb