| |
anonfoo
Posts: 1
Score: 0
Joined: 9/5/2006
Status: offline
|
Hello, I'm trying to write a script that uses xmlhttp to post a file to a form and once submitted the form uploads the file entered in the textbox. The page requires HTTPS and a login and password. I can login find and do a get and it returns the html of the page. The problem is when I submit the file I get an error from response.text saying an error has occured during the file upload. When I look at the web server logs it sees the file im trying to upload but returns an error 302. i think the error 302 is complaining about frames on the page and ie doesnt know how to handle it. If anyone has any ideas it would be a great help. I posted my code and error 302 below: sub send_to_sdx(file_to_send) Dim objSrvHTTP Dim strHTML, sHttpArray, strDateHold, strDate, pos1, pos2 Const adTypeBinary = 1 Const adSaveCreateOverWrite = 2 Const adSaveCreateNotExist = 1 set http = CreateObject("Microsoft.XMLHTTP") err.clear http.open "GET","https://sdx.mydomain.com/tmp/", FALSE, "username", "password" http.send if Err.number = 0 and http.status = 200 then strHTML = http.responseText set xml = CreateObject("Microsoft.XMLHTTP") xml.Open "POST","https://sdx.mydomain.com/tmp/", FALSE, "username", "password" xml.setRequestHeader "Content-Type", "text/xml" xml.Send "upload_file="&file_to_send wscript.echo Err.number wscript.echo xml.status wscript.echo xml.statustext wscript.echo xml.responseText end if end sub output 0 200 OK <html> <head><title>Data Exchange Service</title></head> <body background=images/bkgrd_pg.gif> <table border=0 width=100%> <tr align=left> <td><pre> </pre></td> <td> <img src=images/logo.gif> <h2 align=center>Data Exchange Service</h2> <p align=center>Access by unauthorized users is prohibited.</p> <br clear=all> <h3>File Upload Error</h3> An error has occurred during the file upload:<p> <p><a href=index.cgi>Return to file transfer area</a> </td></tr> </table> </body> </html> Web Server Log Error [prd:etus:web:sdx:sdx2m3] grep username access 10.9.153.35 - - [05/Sep/2006:13:36:13 -0700] "GET /tmp?upload_file=C:\Documents%20and%20Settings\username\Desktop\filename060905.txt HTTP/1.1" 302 0 [prd:etus:web:sdx:sdx2m3] Error 302 Looks like "302" is redirect error based on Google search. CAUSE loadTOCNode(1, 'cause'); Internet Explorer does not properly handle an HTTP/1.1 302 redirect returned from a proxy server or Internet server when the HTTP/1.1 302 redirect is sent to Internet Explorer in two separate TCP frames (one with the HTTP/1.1 302 redirect, and the other with a HTML body containing a page for the new location). When Internet Explorer receives the first TCP frame with an HTTP/1.1 302 redirect, Internet Explorer processes the redirect command and attempts to use the open socket connection to the server that sent the redirect. This occurs because Internet Explorer has not processed the second TCP frame containing the FIN or the "socket close connection" command, so Internet Explorer assumes that the current state of the socket connection is still open. This is an intermittent problem because Internet Explorer may recognize that the socket connection was closed by the server and open a new socket connection to the server if Internet Explorer receives the TCP frames close enough together, or if no HTML body is sent at all. NOTE: With a network packet analyzer, the server returns a standard HTTP "302 - Object Moved" header back to the browser, which is normal behavior for the redirect process. The browser should handle this and go to the redirected site.
|
|