Skip to main content

Notifications

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

ImageSize.pngAttachSize.png

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"

and that is the extent of it.

 

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"

 

 

Comments

*This post is locked for comments

  • WarrenBelz Profile Picture WarrenBelz 145,508
    Posted at
    Show size of attachment or uploaded file

    It is the size relationship between a JSON conversion of the image (to Base64 Text) and the original image

  • Abhilash_Swain Profile Picture Abhilash_Swain 901
    Posted at
    Show size of attachment or uploaded file

    Could you please explain the calculation?

    Thanks
    Abhi