The docs posting for a file only mention this in passing.
For multi part mime message, ie a file, you need to add '--' in front of the boundary string!
Hopefully this will save someone the 2 hours it took me find this.
Here is some code that works:
FileLen = ReadFileToString('WebProducts.csv',FileContents)
WebURL = 'http://' & clip(config:website) & '/admin/au_addproductsupload.php'
PostString = '--' & Boundry & CRLF |
& 'Content-Disposition: form-data; name="localproductsfile"; filename="WebProducts.csv"' & CRLF |
& 'Content-Type: application/octet-stream' & CRLF |
& CRLF |
& fileContents[1:filelen] |
& CRLF |
& '--' & Boundry & CRLF |
& 'Content-Disposition: form-data; name="Submit"' & CRLF |
& CRLF |
& 'Submit'& CRLF |
& '--' & Boundry & '--' & CRLF |
ThisWebClient.SetAllHeadersDefault() ! We recommend you call this before Fetch()
! You may want to modify some properties after this.
ThisWebClient.CanUseProxy = 1 ! Can use a proxy
ThisWebClient.ProxyServer = 'localhost' ! Debug
ThisWebClient.ProxyPort = 81 ! Debug
ThisWebClient.HeaderOnly = 0
!ThisWebClient.Cookie = Cookie
!ThisWebClient.Referer = Referer
ThisWebClient.ContentType = 'multipart/form-data; boundary=' & Boundry
ThisWebClient.AcceptEncoding = ''
ThisWebClient.ContentLength = Len(Clip(PostString))
ThisWebClient.Pragma_ = 'no-cache'
ThisWebClient.AsyncOpenUse = 1 ! Use AsyncOpen 12 seconds (recommended)
ThisWebClient.AsyncOpenTimeOut = 2000 ! up to 12 seconds to connect
ThisWebClient.InActiveTimeout = 9000 ! Set IdleTimeout 90 seconds
!ThisWebClient.Post(WebURL,PostString)