New-UDUpload not working in Pages

Product: PowerShell Universal
Version: 5.6.6

New-UDUpload control not working if I put it in one of the pages in an App.

but it works if the control is in the App

am on 5.6.1 and maybe that is a difference, but in my apps (on pages) UDUpload is working fine (more or less)

maybe provide your code…

New-UDUpload -Text "Upload" -OnUpload {
     Show-UDToast $Body
 } -Id 'upload1'

took the example from PU docs :slight_smile:

Show-UDToast "$Body"

if I use “$Body”

yup, something must be broken.
on 5.6.1 it works even without double quotes

I agree, I also managed to convert $Body to json and the output is not promising … :slight_smile:

Since I am middle in a huge project, I don’t want to upgrade to 5.6.7 if the problem is still there.

I am having troubles too.

When using this code

New-UDUpload -Id “csvUpload” -Text ‘Upload Csv’ -Accept “.csv” -OnUpload {
$Data = $Body | ConvertFrom-Json
$bytes = [System.Convert]::FromBase64String($Data.Data)
[System.IO.File]::WriteAllBytes(“$env:temp$($Data.Name)”, $bytes)
$Page:Filepath = “$env:temp$($Data.Name)”
Sync-UDElement -Id “UploadComplete”
}

I am getting

I tried the basic

New-UDUpload -OnUpload {

    Show-UDToast $Body.Data

}

Getting an error too,

image

Issue remains in 5.6.8

I am on 5.6.8 as well.
It seems your issue is the show-udtoast.

Try the following:

New-UDPage -Url "/upload" -Name "upload" -Content {
    New-UDUpload -OnUpload {
        Show-UDToast $($Body | convertto-json) -duration 10000 -BackgroundColor gold
    }
}

Yow will notice that there is much more in $Body but just the name or the data.
JSON helps you to understand the structure.

You can then use each value as needed.
Even better is using a textbox to display the contents.

New-UDPage -Url "/upload" -Name "upload" -Content {
    New-UDUpload -OnUpload {
        Show-UDToast $($Body | convertto-json) -duration 10000 -CloseOnClick -BackgroundColor gold 

        Set-UDElement -Id "debug" -Properties @{value=$($body|convertto-json)}
    }
    New-UDTextbox -Disabled -Multiline -Id "debug" -FullWidth
}

thanks, I tested again and it seems working without -duration as well.

thanks!

Hi, thanks.

Eventually it was related to permissions, our svc account used to run PSU didn’t have permissions to write on that temp folder, hence JSON file showing an empty object.

1 Like