473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to restrict the uploaded file size in javascript?

I have a problem in javascript. I want to get size of uploaded file by fileupload control in asp.net.
I have googled a lot but i didn't get satisfactory answer. Do anybody know how to do this with the help of javascript .
if any body have idea please tell me how can i get the size so that i can restrict the user to not upload file more than particular size.
i am waiting your reply very eagerily.
May 6 '10 #1
7 2870
Frinavale
9,735 Expert Mod 8TB
As far as I know you cannot check the file size using JavaScript because of security restrictions implemented by the Browser.

I've moved this to the JavaScript forum where the experts will be able to answer this question better.

-Frinny
May 6 '10 #2
ok..thanks
May 6 '10 #3
acoder
16,027 Expert Mod 8TB
Yes, that's correct. You can't check it cross-browser.

I would suggest that you check the file size on the server-side and discard the file if it's too large.
May 7 '10 #4
Frinavale
9,735 Expert Mod 8TB
The problem with this acoder is that sometimes the file is too large for the browser to handle. I have had problems (testing this) in the past and would love the ability to check the file size before uploading....but at the same time I understand why browsers should not be allowed to access files being uploaded.
May 7 '10 #5
acoder
16,027 Expert Mod 8TB
There is something in PHP which allows you to specify the maximum file size on the client-side using HTML. Other languages may have something similar.
May 7 '10 #6
Frinavale
9,735 Expert Mod 8TB
If it's HTML that specifies the size then you should be able to implement it in any web-based application. I'll look into it later :)

Thanks
May 8 '10 #7
acoder
16,027 Expert Mod 8TB
Not quite ;)

It's a hidden field which means absolutely nothing except to PHP code which would use it if found. It's named MAX_FILE_SIZE and is a convenience feature only.
May 8 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Joe | last post by:
Hello, I have IIS 6.0 running on w2k3 Enterprise. I have three upload forms 1 to have restricted uploads .asp 2 to upload plain .asp any extension 3 a FP form upload non .asp
1
by: Sangeeta | last post by:
Hi, Is there a way to find the size of an uploaded file using javascript? I am using <input type="file"/> for uploading the file in an aspx page. Thanks, Sangeeta
2
by: Ruskin | last post by:
I have developed an upload tool, that allows users to upload files (funny that). The asp form object has a 'SizeLimit' property that can be set, to prevent files being uploaded, that are too large....
4
by: Johnson | last post by:
I understand that setting maxRequestLength in Web.config will allow me to limit the size of file users upload to an ASP.NET Web site. Questions: 1. What happens when the user attempts to upload...
7
by: rn5a | last post by:
I am giving users the option to upload files from their hard disk to the server but only those files will be uploaded whose size is less tha or equal to 1 MB. I am using the ASP.NET FileUpload...
4
sumittyagi
by: sumittyagi | last post by:
If we want to upload file, we you the tag: <input type="file" name="fileName"/> Now is it possible to get the size of the uploaded file before submitting it.(at onsubmit) or we would have to...
13
by: marfola | last post by:
I’m trying to find the file size using javascript, before it get uploaded into the server using the following Javascript (I don’t want to use ActiveX because of compatibility problem). function...
1
by: mzmishra | last post by:
Hi, My web.config is set to allow 5MB file size to be uploaded in my application. I want to show one alert message to the user when uploaded file size is greater than that. How can I do the...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
3
Frinavale
by: Frinavale | last post by:
Hi there! I'm hoping that someone knows how to check the size of a file before it is uploaded to the server using JavaScript. I have seen suggested solutions using an ActiveX control to check...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.