Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy a file to the server

Status
Not open for further replies.

jessiejane

Programmer
Oct 29, 2009
32
US
I need to copy a text file to the server using HTTPS protocol. I have to pass the authentication token, the text file, the web url and comment to the server. When the file is transfered, I should get the status whether the file transfer is succesful or not.

Can anyone give me any ideas in doing it. Any help is appreciated.
 
I'm not sure how to send a file using HTTPS and vbs. The following code will accomplish the file copy and verify.

Code:
set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

strFile = "file.ext"
strSourceFolder = "C:\temp\"
strDestinationFolder = "\\server\share\"

objFSO.CopyFile strSourceFile, strDestinationFolder

'wait a sec for the file to copy
wscript.sleep 1000

if (objFSO.FileExists(strDestinationFolder & strFile)) then
   msgbox "File copied to server"
else
   msgbox "File copy failed"
end if

-Geates
 
only thing i have in the archive is for downloading a file, using XMLHTTP .open(GET) and .send method, presume there is a PUT? sorry, cant help anymore

set objXMLHTTP = CreateObject("msxml2.XMLHTTP")
' method, url, asynchronous, username, password
objXMLHTTP.open "GET", URL, False, user, passwd
objXMLHTTP.send


if objXMLHTTP.status <> 200 then
' Log("Error. Status code: " & objXMLHTTP.status & ", " &
objXMLHTTP.statustext & " " & URL)
msgbox "Error. Status code: " & objXMLHTTP.status & ", " &
objXMLHTTP.statustext & " " & URL
exit function
end if


set objStream = CreateObject("ADODB.Stream")
objStream.Type = 1 ' 1 = binary, 2 = Text (default = 2)
objStream.Open
objStream.type = 1
objStream.write objXMLHTTP.responseBody
TimeEnd = Now
objStream.savetofile SavePath, adSaveCreateOverWrite
BytesRcvd = objStream.size
BytesExpect = objXMLHTTP.getResponseHeader("Content-Length")
objStream.Close


set objStream = Nothing
set objXMLHTTP = Nothing
 
objXMLHTTP.open "GET", URL, False, user, passwd

In the code, instead of GET can we use POST?

As this is just the file tranfer from my local machine to the server, I do not have user name and passwd but the authentication token. How would I use authentication token instead of user name and password.

Any help is really appreciated.
 
I am using only VBscript to upload the file to the server.

Function CopyFile(AuthToken, url, datafile, comments)
Set xmlhttp = new ActiveXObject("Microsift.XMLHTTP");
xmlhttp.open("POST", url, False)
xmlhttp.send(AuthToken)-----Would this be true?
Instead of giving user name and password the code has authentication token?
How would i send the datafile to the server and the file is 15MB?

Any help is really really appreciated. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top