1219
Views
11
Comments
File Size
Question
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.
2012-03-02 13-17-21
Paulo Ramos
Staff
Hi,
You can use the BinaryDataSize action from the BinaryData extension.
2012-03-16 12-21-09
João Rosado
Staff
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
2020-04-29 14-31-37
Charles Betman

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.

2019-11-12 17-31-26
Justin James
 
MVP

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

2020-04-29 14-31-37
Charles Betman

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 :-(

2017-01-23 14-38-23
João Batista
Staff

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.

2020-04-29 14-31-37
Charles Betman

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 :-)

2017-01-23 14-38-23
João Batista
Staff

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.

2020-04-29 14-31-37
Charles Betman

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 :-)

2017-01-23 14-38-23
João Batista
Staff

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!

2020-04-29 14-31-37
Charles Betman

Thnx Joao, I'll give it a try.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.