I am working on a method to transfer files using XmlHttp in VBS. The generic approach,
set HTTP = WScript.CreateObject("Microsoft.XMLHTTP")
Set Streamer = CreateObject("ADODB.Stream")
Streamer.Type = 1' set to binary
Streamer.Open
Streamer.LoadFromFile(FSO.GetAbsolutePathName(Filename))
HTTP.open "POST", FinalUrl, true
HTTP.SetRequestHeader "Content-Type", "multipart/form-data"
HTTP.send Streamer.Read()
works just fine. However, I have extra things hoping to show upload progress (we will be uploading large files). On the server side, we have
chunk = CHUNKSIZE
count = Request.TotalBytes
application("status")="Got count"
set stream = CreateObject("ADODB.Stream")
stream.Type = adTypeBinary
stream.Open
do while count > 0
stream.Write Request.BinaryRead(chunk)
count = count - chunk
if count < chunk then chunk = count
loop
stream.SaveToFile ServerFullPath, 2
We have a progress bar method on the server that works just fine and exactly as expected if we use a browser to perform the upload (ie. use <input type="file">
on a form). As soon as the submit button is clicked, our progress meter starts counting (not shown) and the application statement executes immediately.
However, the VBS method shown above seems to wait until the entire file is uploaded before anything happens. For a large file, the application statement does not execute until quite some time has passed.
We have done a lot with inspecting headers, inserting boundaries, etc., to verify that the binary data received on the server is identical using the two client methods (IE or VBS) but nothing seems to let the server proceed until the entire upload is completed when the XmlHttp object is used.
Is this a lost cause? Is there something about the way that IE posts a file-upload that allows the same server script to proceed?
Any thoughts or pointers would be greatly appreciated!