0 votes

I'm using JavaScript.eval(start_code) in _ready to evaluate:

var input = document.createElement("input");
input.type = "file";
input.id = "fileImporter";
document.body.appendChild(input);
input.click();
Godot version 3.3.3
in Engine by (51 points)

1 Answer

0 votes
Best answer

Hi,
most browsers dont allow the fileInput to be clicked by script when it is not triggered by a user input event. Its a safety feature.
Everything else works just fine for me.

by (4,084 points)
selected by

Since you seem to know about this kind of thing, is it possible to use an external JavaScript API? If not, I'm probably gonna have to build godot from scratch.

Maybe you want to use the "File System Access API"

read about it here:
https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
and here:
https://web.dev/file-system-access/

But be aware, this API is currently in status "Working Draft"

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.