/    Sign up×
Community /Pin to ProfileBookmark

Document_size on file upload,

Hiya guys, I’m new here and have carried out the site instructions. Search for an answer before buggin’ us! No, seriously, I just wanted to see if anyone can suggest an update on a 2003 post here re: checking a file size prior to upload, thus eliminating the server round-trip before telling the user his file is too large.

I am building a site that will include both textual data (a user text upload file) and a MySQL database connection, and a directory full of images. The user will more or less design his own site then. However, I would like to be able to check a file size before it gets uploaded, especially useful if we are talking about a large image.

I know that I can do all the usual tests on the temp file in PHP before it’s admitted. But is there a way using Client-Side Javascript?

Thanks for any help and light you might shed on this.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@felgallDec 04.2005 — Javascript has no file access whatsoever and cannot even see the files so is unable to tell how big they are.

You can set a file size limit in the form so that files bigger than the specified limit will not upload in the first place. For example to limit it to 1000 bytes add the following field to the form.

<input type="hidden" name="MAX_FILE_SIZE" value="1000">
Copy linkTweet thisAlerts:
@john1001authorDec 04.2005 — That's just what I've been using. I was looking for a shortcut to obviate that server round-trip. Never mind, thanks anyway.
×

Success!

Help @john1001 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...