Is there any way to get the size of a POST request in javascript? I want to check the size of a file before uploading it via a c# handler so I can tell the user to upload a smaller file.
Thanks in advance.
Is there any way to get the size of a POST request in javascript? I want to check the size of a file before uploading it via a c# handler so I can tell the user to upload a smaller file.
Thanks in advance.
It's not possible for JavaScript to access details of a file on the users machine. There would be major security implications if this was possible.
You will need to upload the file and check its size at that stage. That is best practise anyway, as you shouldn't assume anything about your users environment. In this case they may not have JavaScript in the browser.
Short answer: no.
Long answer: Possibly, but the script would need to be granted access to the local file system by the user via something like a signed ActiveX Object or something like an HTA. I don't know the exact details around this as I've never done it (Down that path, there be dragons!)