2

is it possible to set a static value for input type= file

 <input type="file" id="myfile" value="empty" name="myfilename">

 $('[name=myfilenmae]').val();

it returns ''

but need to get

empty

venkat
  • 21
  • 3
  • `$('[name=myfilenmae]').val() || 'empty'` – Arun P Johny Dec 19 '14 at 03:38
  • `''` is an empty string. If you want to check for that and convert it to `'empty'` for some reason, you can always use an `if` statement. (`($('[name=myfilename]').val() || 'empty')` is shorter here, I guess.) – Ry- Dec 19 '14 at 03:38
  • possible duplicate of [Dynamically set value of a file input](http://stackoverflow.com/questions/1017224/dynamically-set-value-of-a-file-input) – elixenide Dec 19 '14 at 04:58

1 Answers1

0

No, you cannot preset (or dynamically set) the value of a file field. Allowing that would raise a huge security risk, as explained in this answer.

Community
  • 1
  • 1
elixenide
  • 44,308
  • 16
  • 74
  • 100