0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

javascript - file

Posted at

■inputのtype=file選択時にjsでバリデーションする【vue.js】
https://taupe.site/entry/input-typefile-validation/

■JavaScriptのswitch文で正規表現を使う方法を現役エンジニアが解説【初心者向け】
https://techacademy.jp/magazine/35356

■JavaScript で URL やファイルの拡張子を取得する
https://loumo.jp/archives/23134

実際のコード

    fileTypeValidate() {
      switch(true) {
        case /.csv$/.test(this.uploadFile.name):
          console.log('csvです')
          this.getCsvData()
          break
        case /.xlsx$/.test(this.uploadFile.name):
          console.log('xlsxです')
          this.getXlsxData()
          break
        case /.xls$/.test(this.uploadFile.name):
          console.log('xlsです')
          this.getXlsData()
          break
      }
    }

this.uploadFile.nameでファイル名とれた!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?