Dr. Rajesh Rolen
Dr. Rajesh Rolen

Reputation: 14285

How to set text in file (html input type)

How can we set text in html file uploader.

Is it possible using JavaScript?

Upvotes: 1

Views: 2872

Answers (2)

Marek Kwiendacz
Marek Kwiendacz

Reputation: 9814

You cannot set this (security reasons - only user can select file in browser ), but if you need it you can clear this field using this script:

$get('FileUploadCtrlId').outerHTML="<input type=file style='WIDTH: 400px' id ='FileUploadCtrlId'>"

Upvotes: 0

Quentin
Quentin

Reputation: 943185

You cannot. The value attribute is ignored, and the DOM value property is readonly.

Otherwise <input style="display: none" type="file" name="mine-now" value="path-to-some-common-sensitive-file">

Upvotes: 4

Related Questions