Hi all,
Is it possible to determine the file size of an uploaded file?
Kind regards,
Vircos
File size of an uploaded file
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 97
- Joined: Thu Sep 13, 2007 6:07 am
- Location: The Netherlands
-
- Ebase User
- Posts: 53
- Joined: Thu Sep 13, 2007 9:02 am
- Contact:
Have a look at this link which should give you some options for a custom function :-
http://stackoverflow.com/questions/1165 ... fficiently
regards,
Mark
http://stackoverflow.com/questions/1165 ... fficiently
regards,
Mark
0 x
-
- Ebase User
- Posts: 4
- Joined: Wed Jun 20, 2012 6:19 am
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Here's a Javascript function to get file length. Returns -1 if the file doesn't exist:
Code: Select all
function getFileLength(path)
{
if (path)
{
var f = new java.io.File(path);
if (f && f.isFile())
{
return f.length();
}
}
return -1;
}
0 x
-
- Ebase User
- Posts: 4
- Joined: Wed Jun 20, 2012 6:19 am
Thanks that function works for me.
The only thing (if someone wants to use it) is to keep in mind to add backslashes to the filename to escape the backslashes used.
For example
D:\folder\image.jpg must be
D:\\folder\\image.jpg
I've used this funtion to do that:
The only thing (if someone wants to use it) is to keep in mind to add backslashes to the filename to escape the backslashes used.
For example
D:\folder\image.jpg must be
D:\\folder\\image.jpg
I've used this funtion to do that:
Code: Select all
function addslashes(str) {
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\0/g,'\\0');
return str;
}
0 x
Who is online
Users browsing this forum: No registered users and 12 guests