如何将csv文件插入firebase?

时间:2018-02-09 14:42:59

标签: javascript php firebase

上传表单

<form method="post" action="import.php" enctype="multipart/form-data">
                    <fieldset>
                        <div class="form-group">
                          <input type="file" name="file"/>
                        </div>
                    <input class="btn btn-success" type="submit" name="submit_file" value="Submit"/>
                    </fieldset>
                </form>

可能的火基......

var messagesRef = firebase.database().ref('user');

document.getElementById('form').addEventListener('submit', submitForm);

function submitForm(e){
  e.preventDefault();

  var name = getInputVal('name');
  var email = getInputVal('email');
  var phone = getInputVal('phone');

  saveMessage(name, email, phone);

  document.querySelector('.alert').style.display = 'block';

  setTimeout(function(){
    document.querySelector('.alert').style.display = 'none';
  },3000);

  document.getElementById('form').reset();
}

function getInputVal(id){
  return document.getElementById(id).value;
}

function saveMessage(name, email, phone){
  var newMessageRef = messagesRef.push();
  newMessageRef.set({
    name: name,
    email:email,
    phone:phone,
  });
}

我知道csv文件数据可以添加到mysql中但是firebase怎么样?我想上传excel文件数据并存储在firebase中,而不是逐个在Web表单中插入数据......有没有办法做到这一点?

0 个答案:

没有答案