Solved

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

Posted on 2002-05-11
4
152 Views
Last Modified: 2010-04-09
Is there a way to set a value (in this case descriptive text) to a form field <input type="file">?

/joergen

0
Comment
Question by:jastroem
4 Comments
 
LVL 17

Accepted Solution

by:
dorward earned 50 total points
ID: 7003017
<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
 
LVL 12

Expert Comment

by:lexxwern
ID: 7004005
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
 
LVL 33

Expert Comment

by:hongjun
ID: 7004115
This is being asked umpteen times. There's no way to put text in a input type=file

hongjun
0
 

Author Comment

by:jastroem
ID: 7004342
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Wrapper for APPs 9 76
HTML &#0153 2 17
HTML Display Current Year 5 26
Decoding Special HTML Characters using Javascript? 2 23
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question