dcwm
05-23-2009, 09:09 PM
I have a site under development that allows a punter to upload a single file to the web server. I use ASP.NET. The html fragment that allows the punter to select the file to upload is the well known
<input type=file id=file1 name=file1 runat="server" />
which enables the punter to select a file and populate a textbox with a path such as \Test documents\TestdoxA
The problem is that if this file is bigger than about 4 Mb, the upload process goes wrong and the result can look a mess to the punter.
At the point where \Test documents\TestdoxA appears in the textbox, (and before the punter presses the upload button) I would like to intervene and find the length of the file in bytes. Then, if it is too long, bring up a window to warn the guy off.
Can I do this with Javascript (or anyhow else, for that matter) ? If so, could someone point me at a bit of code that I could make a start with, please ?
<input type=file id=file1 name=file1 runat="server" />
which enables the punter to select a file and populate a textbox with a path such as \Test documents\TestdoxA
The problem is that if this file is bigger than about 4 Mb, the upload process goes wrong and the result can look a mess to the punter.
At the point where \Test documents\TestdoxA appears in the textbox, (and before the punter presses the upload button) I would like to intervene and find the length of the file in bytes. Then, if it is too long, bring up a window to warn the guy off.
Can I do this with Javascript (or anyhow else, for that matter) ? If so, could someone point me at a bit of code that I could make a start with, please ?