Click here to Skip to main content
15,911,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want a client side script(javascrpt) for checking the size of file uploading for file upload control in asp.net(before uploading)..
can any one help for this....
Posted

Add this to your web.config
HTML
<configuration>
  <system.web>
    <httpruntime maxrequestlength="sizeinKB" />
  </system.web>
</configuration>

Replace sizeinKB with numeric value. It has to be in KB. Default is 4096(4MB)
 
Share this answer
 
As JavaScript runs on client-side, it cannot access the local file system. You can't read or write files on the user’s computer because of security feature to prevent sites doing anything they like on your computer. For example writing files or viruses on your computer, So in short you can not calculate the file size using JavaScript.
 
Share this answer
 
Comments
aravindnass 2-Jan-13 4:55am    
but if I select about 17.9MB size file..and click the save button,then the mozilla showing - problem loading page("Connection was reset")
aravindnass 2-Jan-13 4:57am    
but if I select about 17.9MB size file..and click the save button,then the mozilla showing - problem loading page("Connection was reset")..

how can I solve this..?
Niral Soni 2-Jan-13 5:18am    
It is because when you are uploading large file, the actual upload is processed by your server. Depending upon the session timeout defined in the config files, you may receive this message - "Problem loading page ('Connection was reset')"

As far as identifying file size in JavaScript, it is achievable using the ActiveX control, but will only work in IE.
Zafar Sultan 2-Jan-13 6:13am    
Modify your web.config file to allow uploading large files.
aravindnass 3-Jan-13 2:19am    
how can I check this..?
Impossible. If javascript could access the file system, the web would be so insecure, no-one would use it.
 
Share this answer
 
Comments
aravindnass 2-Jan-13 4:55am    
but if I select about 17.9MB size file..and click the save button,then the mozilla showing - problem loading page("Connection was reset")
aravindnass 2-Jan-13 4:55am    
but if I select about 17.9MB size file..and click the save button,then the mozilla showing - problem loading page("Connection was reset")..

how can I solve this..?
Christian Graus 2-Jan-13 13:19pm    
Fix your server setup so that it doesn't time out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900