Multiple file uploads from a csp

I want to upload several files using the html tag

< input multiple="multiple" name="BulkFileUpload" type="file">

. The upload.csp page in the SAMPLE namespace only shows how to extract a single file from the MimeData on the %request object. I cannot fathom how to extract multiple files from the MimeData in the %request object in cache. Can some kind soul explain to me how to do that?

  • 0
  • 0
  • 43
  • 1
  • 1

Answers

Mimedata is subscripted by name and index.

So in your case:

set name = "BulkFileUpload"
for i=1:1:%request.CountMimeData(name)
    set mimeData = %request.GetMimeData(name, , i)
}

On each iteration mimeData variable would hold the stream with one next mimedata.

%request is simply an object of %CSP.Request class, check the docs or code to know how it works.

Additionally you can use this snippet to see what's inside %request, %response and %session objects:

set %response.ContentType = "html"
do ##class(%CSP.Utils).DisplayAllObjects()
quit $$$OK

It seems obvious looking at it now, but i really couldn't see the wood for the trees.

Many thanks.