/    Sign up×
Community /Pin to ProfileBookmark

checking an images size (in KB)

I have a form which uploads files.
I want a way to make sure the file uploaded (first off is an image, so should I make sure the file type is either: gif, jpg, bmp, png, tiff ..) is less than (say… 50K? and is between 200 X 200px and 800 X 1000px?
How do I perform these checks so that if 1 file upload is buggy, the user can simply replace the file untill all is ok and the form is submitted?

to post a comment

2 Comments(s)

Copy linkTweet thisAlerts:
@OverstatementDec 30.2006 — I'm going to go out on a limb and say any solution (assuming there is one)would require the user to agree to run your script which is really annoying. Maybe a serverside script would be able to check the header of your image file before the whole file is sent, giving you the chance to cancel the upload.
Copy linkTweet thisAlerts:
@KorDec 30.2006 — A server-side solution (php, asp...) is to be used. javascript is a client-side language thus it can not detect the size of an upload file.


Help @lukeurtnowski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ

legal: ({
terms: of use,
privacy: policy
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,