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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp upload to a server from a url?

Status
Not open for further replies.

x6213

Programmer
Aug 17, 2005
17
US
I can find hundreds of examples of doing an upload from the client's local machine, but I need one that will upload a zip file to the server from the web.


 
here you go...something like this

Code:
dim objXMLHTTP,URL


DestFolder = "./"

URL = "put the url here"

set objXMLHTTP = CreateObject("Msxml2.ServerXMLHTTP.4.0")


objXMLHTTP.Open "GET", URL, False

[red]objXMLHTTP.SetRequestHeader "Authorization", "authenticationcode"[/red]
 
objXMLHTTP.Send 


set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1

oStream.type = adTypeBinary
oStream.open
oStream.write objXMLHTTP.responseBody


oStream.savetofile DestFolder & strFilename, adSaveCreateNotExist

oStream.close

set oStream = nothing
Set objXMLHTTP = Nothing

You need that red line only if the website has authentication implemented to download any files or content from the site...

-DNG
 
I kept getting 'write file error' until I realized I needed to add strFilename="filename.zip" and it
worked,
thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top