They added other things to scripting that make this, slightly, easier “manually”. No direct “multipart/form-data files” AFAIK in /tool/fetch however.
For example, with some of the new scripting this, you MIGHT, depending on file size/type, using v7.13+ be able to do this in script. But you can see that’s it’s not just "files="that multipart/form-data needs. There is the file’s MIME type, field name from “form”, and the desired filename.
I’ll provide some sample code, but don’t vouch it will work & there are still limits of scripting that still may NOT have a workaround in scripting. Mikrotik added a “:convert to=base64” operation which is what’s needed, in some case, to encode the file data.
:global sendFormDataFile do={
:local urlf $url
:local formFieldName $field
:local fileName $file
:local mimeSeperator "--$[:rndstr]"
:local contentType "Content-Type: multipart/form-data; boundary=$mimeSeperator"
:local fileMimeType "application/octet-stream"
:local formdataMime "\
$mimeSeperator\n\
Content-Disposition: form-data; name=\"$formFieldName\"; filename=\"$formName\"\n\
Content-Type: $fileMimeType\n\
Content-Transfer-Encoding: base64\n\n\
$[:convert from=raw to=base64 [/file/get $fileName content]]\n\n\
$mimeSeperator--\n"
/tool/fetch http-method=post url=$urlf http-header-field=$contentType http-data=$formdataMime output=user
}
$sendFormDataFile url="http://192.168.88.1:80/upload" file=myrouterfile field=formfieldname
More for ideas, than suggesting this is a solution. form-data is tricky, since the other end needs to accept it and it may be looking for some very specific things to accept it. e.g. form-data is really a browser thing, so it kinda depends on the original HTML like what’s contained on the etc tags, on top of just the file data.
But if you can look at the HTTP transfer in a browser or sniffer, you’d have a better idea of how to build it RouterOS script. The above gives example of how to deal with the MIME headers which are critical for form-data. But what field name, encoding etc. etc. is needed depends on the server-end. It may need other form-data to in ANOTHER MIME block to even accept the file, too! But a sniffer or browser inspect of the HTTP headers/data from a browser give you a BIG clue how to build the http-data= needed in /tool/fetch.