• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Check File Size Before Upload

Guest
Dec 03, 2010 Dec 03, 2010

Copy link to clipboard

Copied

hi there guys..

i'm having a problem at the moment.. how can i check the file size before it is submitted to the server?

i was given a task to check if the file size limit is more than 500kb then block the upload and notify user..

according to my workmate.. this is not possible with Javascript or Ajax.. is there any other method i can use?

kindly help.. thanks

Views

2.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 04, 2010 Dec 04, 2010

This is a good answer, but it's worth pointing out that Flash Player is itself an ActiveX control (when run from within IE). In short, you need something beyond code that runs directly in the browser to do this. It can't be done with just HTML and JavaScript in a web page.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at ou

...

Votes

Translate

Translate
Contributor ,
Dec 03, 2010 Dec 03, 2010

Copy link to clipboard

Copied

Pretty sure it can't be done without an AIR app or an ActiveX control or

something like that which gets installed on the user's machine. Otherwise

the browser is the only interface to the user's harddrive, and it's not

allowed to simply run file size checks on local files, for obvious security

reasons.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2010 Dec 03, 2010

Copy link to clipboard

Copied

I once wrote a very simple Active X script to do this.  However, when I ran the page with IE I was prompted to allow that script to run.  With FF, I could not get the script to run.

If there is an answer, it lies elsewhere.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 03, 2010 Dec 03, 2010

Copy link to clipboard

Copied

It can be easily done with a Flash-based upload widget - no AIR or ActiveX control required - provided you are happy to build and deploy for Flash Player 10+. I've built an uploader for a client recently that checks the image size and dimensions and then does a client-side image resizing process and uploads the final image to a CF endpoint.

You want to have a further look into the FileReference API in Flex, here's a good blog post to start with:

http://sujitreddyg.wordpress.com/2008/11/04/filereference-in-flash-player-10/

Cheers

Kai

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2010 Dec 04, 2010

Copy link to clipboard

Copied

LATEST

This is a good answer, but it's worth pointing out that Flash Player is itself an ActiveX control (when run from within IE). In short, you need something beyond code that runs directly in the browser to do this. It can't be done with just HTML and JavaScript in a web page.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Read this before you post:

http://forums.adobe.com/thread/607238

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation