Shikha
Shikha

Reputation: 339

How to pass hard coded file path to File API?

I want file name, size and type using File API in javascript but without any control means I want to pass hard coded file path. Is any solution?

Thanks in advance.

Upvotes: 2

Views: 1812

Answers (1)

GitaarLAB
GitaarLAB

Reputation: 14645

So you want to pass hard coded file path using javascript.

Thank goodness, in javascript (run inside the browser) you can't do that.
Only the user can populate a <input type="file"> element or File objects in a FileList.

On setting, if the new value is the empty string, it must empty the list of selected files; otherwise, it must throw an InvalidStateError exception.

and

The HTMLInputElement interface [HTML] has a readonly attribute of type FileList...

See a thorough write-up including HTML5 features here: Remember and Repopulate File Input

Hope this helps!

Upvotes: 4

Related Questions