1

when upload button clicked on page... want to check filesize selected in fileupload control and stop postback of upload button if file size exceeds... what are the ways to do this using jquery/javascript?

3 Answers 3

1

Although it's hardly a foolproof way, some browser check if you have a hidden input element specifying the maximum filesize like so:

<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />

[edit]It seems that this type of checking was never actually implemented by one of the main browsers. It was merely hoped that they did.

In that case you can only limit the file upload size (clientside) with flash, silverlight, java or some other clientside plugin.

Sign up to request clarification or add additional context in comments.

5 Comments

Not implemented by which one?
@Bruno: which one implements it?
@John Saunders, I have no idea, why do you ask me?
@Bruno: because you asked, "Not implemented by which one?", as though you felt it was implemented on many browsers. I wanted to know which browsers implemente it.
@John Saunders / @Bruno Reis: None of them support it unfortunately. Browser plugins are the only way.
1

You can't, you must use server-side PHP or ASP[.NET] to do so. If it is possible, crackers will be stealing files.

Comments

1

There is no way to implement this in a pure Javascript solution, since for security reasons, Javascript doesn't have access to your local filesystem. The only fool-proof way to do what you want is on the server. Depending on the technology you use, you may be able to intercept the request while it's still being sent and kill it based on the Content-length header.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.