Hi guys, I have a question.
I would like to write a javascript code that uploads a file in an input type="file" of my html page by its name or its path.
Is it possible?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (4)
Can I ask you to explain your use case a bit more?
I want to make an input button in html of file type, to upload a file. But I don't want to click the button and choose the file, I want to write the path of the file in javascript and upload it automatically.
No you can't automatically click and do the file upload in Javascript, because it doesn't have permissions to access your files. That button handles the communication between your application running inside a browser and the file system, you never have access to this for security purposes.
Not sure on what you're trying to achieve with this, but you might want to check out this File System API which might work for what you're trying to do.
web.dev/file-system-access/