'====================================================================== ' https-upload.vbs 1.0 @2009 by Frank4dd http://fm4dd.com/programming ' This script demonstrates a file upload to a WebDAV enabled webserver, ' using https (and proxy settings from IE) with basic web authentication ' ' In Linux I would use curl, but on Windows, curl needs a ton of extra ' libraries (openssl, zlib, etc) to make it work, so using a vbs script ' is in some cases a better way. ' ' Original authors and code references: ' - "ASP - File upload with HTTP Put" by Martin Clark ' ' This program comes with ABSOLUTELY NO WARRANTY. You may redistribute ' copies of it under the terms of the GNU General Public License. '====================================================================== '====================================================================== ' Global Constants and Variables '====================================================================== Const scriptVer = "1.0" Const UploadDest = "https://mywebdavserver.com/uploadurl" Const UploadFile = "localpath-and-file" Const UploadUser = "username" Const UploadPass = "password" Const UploadType = "binary" dim strURL function sendit() sData = getFileBytes(UploadFile, UploadType) sfileName= mid(UploadFile, InstrRev(UploadFile,"\")+1,len(UploadFile)) dim xmlhttp set xmlhttp=createobject("MSXML2.XMLHTTP.3.0") strURL = UploadDest & "/" & UploadFile msgbox "Upload-URL: " & strURL xmlhttp.Open "PUT", strURL, false, UploadUser, UploadPass xmlhttp.Send sData Wscript.Echo "Upload-Status: " & xmlhttp.statusText set xmlhttp=Nothing End function function showresult() Wscript.Echo "Complete. Check upload success at: " & strURL end function function getFileBytes(flnm, sType) Dim objStream Set objStream = CreateObject("ADODB.Stream") if sType="binary" then objStream.Type = 1 ' adTypeBinary else objStream.Type = 2 ' adTypeText objStream.Charset ="ascii" end if objStream.Open objStream.LoadFromFile flnm if sType="binary" then getFileBytes=objStream.Read 'read binary' else getFileBytes= objStream.ReadText 'read ascii' end if objStream.Close Set objStream = Nothing end function '======================================================================= ' End Function Defs, Start Main '======================================================================= ' Get cmdline params and initialize variables If Wscript.Arguments.Named.Exists("h") Then Wscript.Echo "Usage: https-upload.vbs" Wscript.Echo "version " & scriptVer WScript.Quit(intOK) End If sendit() showresult() Wscript.Quit(intOK) '======================================================================= ' End Main '=======================================================================