File Size

  
hi everyone.

 i  uploaded one file in my application in list. i have one column like filesize . i wanted to know the size of the uploaded file. i write the below query.

length(Filename.content)

in value.  this value i assigned to variable  of  filesize.
 but i get the text to binary data conversion error.. can anybady help me .

Regards,
sattibabu vatti.
Hi,
You can use the BinaryDataSize action from the BinaryData extension.
Hi Sattibabu,

If you want to use that in queries I recommend you to create on your Entity a Filesize attribute and fill it with the method Paulo suggested during the Upload of the file.
Otherwise you will have performance issues in your screen.

Regards,
João Rosado

Hi, this is an old topic, but hopefully my post will be read :-)

Does anyone know how to determine file properties (like the size, but perhaps also other properties like date modified) BEFORE uploading the file?

Might be useful for example to set limits to the file size.

Charley wrote:

Hi, this is an old topic, but hopefully my post will be read :-)

Does anyone know how to determine file properties (like the size, but perhaps also other properties like date modified) BEFORE uploading the file?

Might be useful for example to set limits to the file size.

No, the browser does not allow access to the local filesystem.

J.Ja

Thnx Justin.
Not so happy with this ... means you really have to upload a file of (let's say) 100MB to reply to the user the maximum size of a file can only be 1MB? Not so good for performance I guess :-(

Hello Charley,

there are some ways using jquery. Here is one:


$(document).ready(function() {
  $('#fileUploadControl').on('change', function(evt) {
    console.log(this.files[0].size);
  });
});


The #fileUploadControl is the id of the file upload control. This is logging on the console of the browser the size of the selected file in bytes. Be aware that this might not work on older browsers.

Ok, thnx Joao ... good to hear there are ways to check the size first (although the suggested jQuery is not a generic solution for every browser yet I understand).

I would like to try your suggestion, but now I have to find help how/where to implement the jQuery and how to use it the right way ... I'm a newbie in this, sorry :-)

there are other solutions that mix this, and usage of activex to support older versions of Internet Explorer.


To use that snippet, it should be fairly simple, just place this code in the javascript, making sure that the id of the control is dynamically populated using the control.Id property.

I managed to implement a simple JavaScript function that determines the size of the selected file. From the JavaScript I update a (hidden, diabled) input field so that I can use the size in my OutSystems environment.

Question 1: this works fine, but is there perhaps another way to return a value from a JavaScript function to be used in the OutSystems environment?


Another thing I did was, depending on the maxFileSize I allow, from within the JavaScript click 1 of 2 hidden buttons on the web screen, activating a screen action (one for a file that is too large, and one for a file that can be handled).

Question 2: can anybody explain at what moment OutSystems really uploads a selected file? I mean, in the screen action that handles a file that is too large in my example the only thing I do is displaying a message; does that mean the file won't be uploaded to the server? Is it only uploaded when the content is used?


Lots of questions, I know, but I learn a lot of it :-)

Hello Charley


Regarding Question 1: that is a good approach to pass a value from javascript to the server.


regarding question 2: if I am not mistaken, the file content is only uploaded when you have a submit button being clicked. If you have an ajax submit button to display the feedback message, then I believe the file doesn't get uploaded. You can easily confirm this by selecting a really large file and in chrome then you can see the upload going on the left bottom.


Hope this could help!

Thnx Joao, I'll give it a try.