Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16943

Re: How to validate a file in a javascript

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: How to validate a file in a javascript
Date Mon, 29 Oct 2012 08:57:03 +0000 (UTC)
Organization A noiseless patient Spider
Lines 22
Message-ID <k6lgcv$vth$2@dont-email.me> (permalink)
References <804583d9-ac09-492c-b488-8989cb13727c@googlegroups.com> <k6k8kh$svj$1@speranza.aioe.org> <b1e733ca-8409-410a-8f74-bf5c9a6014cc@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Mon, 29 Oct 2012 08:57:03 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="986f797cbd3b8f473a4775d73e9098bc"; logging-data="32689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19VYYn5yF9vqORwxQEbdwDRjUMRZ1R2n20="
User-Agent Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2)
Cancel-Lock sha1:F3Tu3l9CIiPAd6Y6Yg0IOdn4Xcw=
Xref csiph.com comp.lang.javascript:16943

Show key headers only | View raw


On Sun, 28 Oct 2012 23:32:33 -0700, Katja wrote:

>> I wouldn't trust on file extensions. As a just a warning for user then
>> 
>> it is ok. Just my "5 cents".
>> 
> I know but I still need it =)

Javascript has no direct access to the filesystem. Thus, it can not 
reliably determine the size of a file. At best, you can do (sub)string 
comparisons and regex checks against a file name entered into a form 
field.

You can also use the accept attribute in html to constrain the mime type 
of the uploaded file eg:

<input type="file" accept="image/png,image/gif,image/jpeg" name="blah"( /
)>

Rgds

Denis McMahon

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to validate a file in a javascript Katja <kate.kokatjuhha@gmail.com> - 2012-10-28 11:56 -0700
  Re: How to validate a file in jquery Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-28 21:11 +0000
  Re: How to validate a file in a javascript Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 22:38 +0100
    Re: How to validate a file in a javascript Katja <kate.kokatjuhha@gmail.com> - 2012-10-28 23:32 -0700
      Re: How to validate a file in a javascript Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-29 08:57 +0000
        Re: How to validate a file in a javascript Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-29 15:20 +0100
          Re: How to validate a file in a javascript Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-29 23:22 +0000
            Re: How to validate a file in a javascript Jeff North <jnorthau@yahoo.com.au> - 2012-10-30 17:11 +1100
              Re: How to validate a file in a javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-01 21:51 +0100
        Re: How to validate a file in a javascript Dr J R Stockton <reply1244@merlyn.demon.co.uk.invalid> - 2012-10-30 19:47 +0000

csiph-web