문제

I already know how to create buttons using dat.GUI (passing in functions as described in this question: Is it possible to create a button using dat.gui). I want to make a button that triggers a load file event like you would do with <input type="file" id="file" name="file" enctype="multipart/form-data" /> Is this possible?

도움이 되었습니까?

해결책

(Based on Programmatically trigger "select file" dialog box)

You call the hidden input button from the dat.GUI button's function.

<input id="myInput" type="file" style="visibility:hidden" />

<script>
var params = {
    loadFile : function() { 
            document.getElementById('myInput').click();
    }
};
var gui = new dat.GUI();
gui.add(params, 'loadFile').name('Load CSV file');
</script>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top