'Upload file from local through Chrome console

I have an input element like that.

<input type="file" name="submitedFile" class="hidden-file-input">

I would like to upload file automatically by JS from Chrome console.

Something similar to sendkeys in Selenium.

I found this answer here.

Then I tried something like that.

document.getElementsByName('submitedFile')[0].value='C:\\myfolder\\myfile.txt';

But I have this error.

Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.

How I can solve this error ? or is there another way to upload file from my local device to the browser through Chrome console automatically ?

Edit:

I think the problem that the browser cannot access the local files in the OS. For that, I tried to upload the folder in the Filesystem in the Sources of Chrome. But I still have the same error. Is there a way that I can use the files in the Filesystem ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source