View Full Version : about <input type=file>

01-13-2004, 05:19 PM
the code is:
<input type="file" name="userFile2" size="80" value="C:\" onkeypress="KeyPress()">

But the "C:\" does not show in the text area. Who knows how to show it.

01-13-2004, 05:25 PM
You can't set the value attribute of file upload form elements for security reasons. Consider this: someone could set the default value to a sensitive file, for example, a password file, then call the form element's submit method (or hide the element and let the user submit the form), and thus uploading senstivie data to the server. By not being able to set the value attribute of these kind of elements prevents this from happening. Moreover, when you select a file from the dialog, it will print the complete path in the textbox (rendering setting the value attribute useless), you also need to consider not everyone uses Windows as their operating system. I, for example, run Red Hat Linux, and there is no such thing as C:\ here.

01-14-2004, 04:35 AM
What fredmv said. The value attribute of file input is read-only.

01-14-2004, 10:12 AM
Thank all of you to reply the question. But may I use Cookies to record the path, and to be shown next time the user open the page?

01-14-2004, 10:17 AM
Yes of course, as long as you don't display it in a file field. Search for cookie-related threads in this forum or google for cookie scripts if you don't have any.