2
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 1 year has passed since last update.

これからはJavaScript勉強しよう 1回目

Last updated at Posted at 2024-03-02

次回はCSVファイルを読み込んでみる

<!DOCTYPE html>
<head>
<title>テスト画面</title>
</head>
<body>
<form name="myform">
<input name="myfile" type="file">
</form>
<script>

var form = document.forms.myform;

form.myfile.addEventListener( 'change', function(e) {
    // ファイルを取得する
    var result = e.target.files[0];

    // ファイルを読み込む
    var reader = new FileReader();
    reader.readAsText(result);

    // ファイルが読み込まれた後の処理
    reader.addEventListener('load', function() {
        document.write(reader.result);
    })

})
</script>
</body>
</html>
2
0
2

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
2
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?