Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set default value for a input file form [duplicate]

Tags:

Possible Duplicate:
Dynamically set value of a file input

I have an input file HTML form and I want to set the initial value for the file path in an HTML form . I try to change tag "value" but it doesn't work anyway. <input type="file" name="testcase" value= "C:\test.txt">

Please give me some advice for this small problem. Thanks.

like image 382
aladine Avatar asked Apr 19 '10 03:04

aladine


People also ask

How do I change the default value of a input type file?

The only way to set the value of a file input is by the user to select a file. This is done for security reasons. Otherwise you would be able to create a JavaScript that automatically uploads a specific file from the client's computer.

What is the value of input type file?

A file input's value attribute contains a string that represents the path to the selected file(s). If no file is selected yet, the value is an empty string ( "" ). When the user selected multiple files, the value represents the first file in the list of files they selected.

Can I use input file multiple?

When present, it specifies that the user is allowed to enter more than one value in the <input> element. Note: The multiple attribute works with the following input types: email, and file. Tip: For <input type="file"> : To select multiple files, hold down the CTRL or SHIFT key while selecting.

How do you clear the input type file?

To reset a file input in React, set the input's value to null in your handleChange function, e.g. event. target. value = null . Setting the element's value property to null resets the file input.


1 Answers

From HTMLHelp.com :

The file input type creates a field through which users can upload files from their local computer or network. The VALUE attribute specifies the name of the initial file, but it is typically ignored by browsers as a security precaution.

Therefore, setting an initial value is not supported.

like image 169
anonymous Avatar answered Sep 24 '22 08:09

anonymous