Click to See Complete Forum and Search --> : to get filesize in dot net
akshatha306
July 26th, 2006, 01:49 AM
hi People
i have a File Upload asp control..
i have to do a validation to see if the selected file is more than 200 GB
now how i do it.. can i get the file size using javascript...
If no,
How can the size of the file got from the aspx.cs file.
Somebody who's familiar with this
Thank you,
Akshatha
humptydumpty
July 26th, 2006, 02:04 AM
you can try this .may be this One help you.
function A()
{
var oas = new ActiveXObject("Scripting.FileSystemObject");
var d = document.a.b.value;
var e = oas.getFile(d);
var f = e.size;
alert(f + " bytes");
}
</script>
</head>
<body>
<form name="a">
<input type="file" name="b">
<input type="button" name="c" value="SIZE" onClick="A();">
</form>
</body>
</html>
And have a look on this Link
http://www.quirksmode.org/js/filesize.html
Thanx
akshatha306
July 26th, 2006, 05:56 AM
That doesn't work...
Can't we do it server side itself(.aspx.cs file)
Alsvha
July 26th, 2006, 06:49 AM
I have not worked with the fileupload control myself yet, but I doubt you can do what you wish serverside, because for it to be done serverside, you need to have the file uploaded.
However, there is a setting for the httpRuntime called maxRequestLength in which you can set the max size of the request, and thus the file. However, again - I've not worked with this, so how it works excatly I can't tell you, but I recommend you checking out the documentation: http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx for the fileupload.
For a check as you request, I'd personally do it client side; meaning javascript - although thinking of uploading an up to 200GB file via fileupload seems .... excessive and I'm not even sure you can get that done using that technique and I'd advice you to use FTP to upload the file(s) if they are large.
akshatha306
July 26th, 2006, 07:39 AM
hi alsvha,
its not 200GB.. it was a mistake. its 200MB.:-)
Alsvha
July 26th, 2006, 07:50 AM
I'd still say 200MB is a large size to upload via HTTP fileupload, and would still advice you to look into making it into an FTP upload :)
I've personally had problems with server time-outs and all sorts of problems, when clients were uploading 40MB files even on "fast-ish" connections.
Just my personal experience talking.
akshatha306
July 26th, 2006, 08:26 AM
hey thanks alsvha
i got it from the link that u sent.
Thanks a lot.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.