· Nov 1, 2016

File size.

Hi everybody,

My name is Sérgio Fernandes and I'm from Brazil.

I need to get the size of file that the user wants to upload in my application.

I'm getting it name with %request.GetMineData("fileName").FileName, but not found it at Ensemble documentation how would i get the size of file.

My version is Ensemble 2013.1.6.950.0 and I'm doing it at csp.


Discussion (3)0
Log in or sign up to continue

Yes, you right, but you should also remember, that your file can also be in another property, like `Content`. 

I think that you want to set some limit, for file which is available to upload to server. And in this case, this file will be uploaded at the server any way. And I would recommend to use FileAPI on client side, and you can check file size before loading it to the server.

I would suggest to use client side javascript API to check the file size, instead of uploading it to server and check it.

I got a nice article on a blog.

<script language='JavaScript'> 
function checkFileSize(inputFile) {
        var max = 3 * 512 * 512; 
        if (inputFile.files && inputFile.files[0].size > max) { 
                alert("File is too large to upload."); 
                inputFile.value = null; 
} </script>