• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

set a value to a <input type="file"> field

Is there a way to set a value (in this case descriptive text) to a form field <input type="file">?

/joergen

0
jastroem
Asked:
jastroem
1 Solution
 
dorwardCommented:
<label accesskey=C><input type="file" name="uploaded"> Descriptive text</label>

It is not possible to place text inside the form field, for security reasons. The closest I can think that would do it (and I do not consider this a good solution, it breaks to easily) would be to use CSS to position a <div> on top of the field, and then set the div to display: none and set the focus to the input when the div had its onclick, or the form field had its onfocus event triggered.
0
 
lexxwernCommented:
please clarify...

do you want some descriptive text or do you want a certain file to be already in the field when the page is loaded.

the second case is not possible.

for the first, there are many workarounds...what dorward told you is one, you can also have a tooltip or a stutusbar message <-- BAD!

0
 
hongjunCommented:
This is being asked umpteen times. There's no way to put text in a input type=file

hongjun
0
 
jastroemAuthor Commented:
Thanks a lot for the information.

I understand the teh security issue - unfortunately there are some cases where it could be really goog to place a previous uploaded file in the file field... like in this case where a record is updated.

I have solved the problem in another - less nice - way.

/ joergen
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now