Sunday 15 April 2012

Vba Upload Text File -


I am trying to upload a plain text file and get an error on a classic ASP page.

  & lt; P & gt; Microsoft VBScript Runtime & lt; / Font & gt; & Lt; Font face = "aerial" size = 2> error '800a01a8' & lt; / Font & gt; & Lt; P & gt; & Lt; Font face = "aerial" size = 2 & gt; Required objects: 'Field (...)' & lt; / Font & gt;  

HTML code

  & lt; Form action = "upload.asp" method = post ENCTYPE = "multipart / form-data" & gt; File: & lt; Input type = "file" class = "form_field" name = "file1" accept = "picture / jpeg" & gt; & Lt; Input type = "submit" class = "form_pb" name = "action" value = "send file" & gt; & Lt; / Form & gt;  

Vba code to set the post variable and send the request. String = "a832972453175" in the form of const STR_BOUNDARY, as the dim nFile, the integer as the dim baBuffer () as the bit dim as the espostadata string .... '--- file Read nFile = FreeFile Open sFileName for Binary Access Read as NFile if LOF (NFL) & gt; 0 Then get Redeem Babber (0 to LOF (NAFile) - 1) Get the NAF as a byte, Babber Espostadata = Termination (Babber, VBUDodode) Close if nFile sPostData = "-" & amp; STR_BOUNDARY & amp; VbCrLf & amp; _ "Content-disposition: form-data; name =" "1 file"; Filename = "" "& Mid $ (sFileName, InStrRev (sFileName," \ ") + 1) & amp;" "" & Amp; VbCrLf & _ "Content-Type: Text / Plain" & amp; ; VbCrLf & VbCrLf & amp; _SpostData & amp; VbCrLf & amp; VbCrLf & amp; _StR_BOUNDARY & VbCrLf & amp; _ "Content-Disposal: Form-Data; Name = "" Action "" & "VbCrLf & amp; _VbCrLf & amp;" Send File "& amp; VbCrLf & amp; _" - "& amp; STR_BOUNDARY & amp;; -" With WinHttpReq Upload Request Open "Post", SURL, Wrong .setRequestHeader "Content-Type", "Multipart / Form-Data; Termination of terminology = "&" STR_BOUNDARY .setRequestHeader "user-agent", "Mozilla / 4.0 (compatible; MSIE 6.0; Windows NT 5.0)".

End of sPostData Near source code page which is a classic ASP page and is executed with VBSScript running on the upload server.

The error is that File1 argument = "" and then the upload does not start.

Despite accepting the attribute in the html code is only for "image / jpeg" I navigate from a browser I can upload normally when I am.

I think there is something wrong with my espoddata variable Vba code.

The file with upload functions is here:

Anyone can see what I'm doing?

I have discovered that the border was reconstituted by the page "myboundary" +; charset = UTF-8 .

This mother Solutions in the add request charset header. Upload with WinHttpReq 'Request Open "post", SULL, false.setRequestHeader "content type", "multicast / form-data; charset = UTF-8; boundary =" & amp; STR_BOUNDARY .setRequestHeader "User-agent", "Mozilla / 4.0 (compatible; MSIE 6.0; Windows NT 5.0)". End the term (sPostData) with the "content-type" .setupdate; multipart / form-data; charset = UTF-8; border = "&

.setRequestHeader Amp; STR_BOUNDARY


No comments:

Post a Comment