Data

Show size of attachment or uploaded file

Have you ever wanted to show or use the size of an uploaded file – the process is below

Attachment

Firstly, you need a hidden image control with the Image

Last(AttachmentControlName.Attachments).Value

Then on the OnAddFile (and OnRemoveFile if you want)

UpdateContext(
   {
      varJSON: 
      JSON(
         YourHiddenImageName.Image,
         JSONFormat.IncludeBinaryData
      )
   }
)

Then the Label below has the Text

"Last Attachment: " & (Len(varJSON) - 814) / 1370000 & " Mb"

Uploaded file

A similar, but less complex process – on the OnChange of the AddMediaButton

UpdateContext(
    {
      varJSON: 
      JSON(
         UploadedImageName.Image,
         JSONFormat.IncludeBinaryData
      )
   }
)

and the Label below

"Image Size: " & (Len(varJSON) - 814) / 1370000 & " Mb"

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *