• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Detect if file size is too large before uploading

Fufu

Well-known member
#2
xenForo does not already check the file? Nice suggestion. I have not tried to upload a oversized file myself. I will have to try this.

I almost want to add another suggestion to this thread, but may an add-on would help cause it probably be server intensive what I would propose.
 

EQnoble

Well-known member
#6
The only thing I know of for ie that you can do to check filesize before a transfer is using filesystem object which needs activex which most people leave disabled...

http://msdn.microsoft.com/en-us/library/2z9ffy99(v=vs.84).aspx

Code:
var fso, f1;
fso = new ActiveXObject("Scripting.FileSystemObject");
f1 = fso.GetFile("c:\\test.txt");
The following is a snippet I had in a directory full of snippets, if I can find the source of the snippet I will update it (though relying on activex is kinda dookie so it is probably pointless to mention)...


Code:
 if ($.browser.msie) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fPath = $("#" + fileid)[0].value;
var objFile = fso.getFile(fPath);
var fSize = objFile.size;
fileSize = fSize / 1048576;
}
 

EQnoble

Well-known member
#8
IE is often problematic, can't it just be done so that it works for everyone using a proper browser but reverts to the current behavior for people using IE?
I think if anything is to be done to it at all that this is the best way to go about it. Generally my upstream is fast enough where it doesn't matter to me personally but for those with slower connections and for people with weak servers this has the capability to reduce waste on both server and client sides I suppose.