File upload howto

Anyone have an example of how to upload a CSV?

I have the UDInput loaded and prompting for the file, once selected however nothing happens.


I believe Adam said this is coming in the next major version, see here:

Its already in the current version from what I can see in the change logs. I also have it on a page. Just once I select the csv, I don’t know how to process it.

I’m currently playing around now.

I know it’s a few days old this thread but @adamdriscoll was kind enough to upload a youtube video showing just this. So I would recommend looking at Adam Driscolls video on youtube.

maybe this can help you. didn’t find it in the docs either which is a little annoying.

New-UDInput -Title "File Upload" -id "File" -Content {
                New-UDInputField -Type 'file' -Name 'File' -Placeholder 'give me your csv' 
            } -Endpoint {
                    Show-UDToast -Message "$file"
1 Like

I’ll make sure to get this documented. Sorry about that.

I’ve looked for the video you mentioned, but can’t find it. Can you share the URL?

How do you reference the original file name/extension in the endpoint scriptblock?
It appears that the file contents are correctly passed into the Endpoint block, but I’m not sure how to reference the original file name and extension in the endpoint. In my case, I’m trying to allow the user to upload an image, so i need to know the original file extension in order to save/process the data properly in the endpoint block.

Here’s an example of using the new binaryFile input type. It provides the file name and the binary data.

New-UDInput -Title "Stuff" -Content {
   New-UDInputField -Type binaryFile -Name file 
} -Endpoint {

   $fileStream = [IO.File]::Create($File.FileName)
   $stream = $File.OpenReadStream()

That’s perfect. Thanks, Adam!

For those who come across this later, when using type binaryFile, the $File object passed to the Endpoint is of type [Microsoft.AspNetCore.Http.Internal.FormFile]. Properties and methods are documented here: