0

Hi I have small requirement, is there any way to update variable value to the input type file value (Browse).

<input type="hidden" value="Testfile - CSV - 100 rows.csv"   id="filePathHdnID" name="filePathHdn" />

<input class="fileType" name="uploadfile" type="file" id="idUploadFile"/>

Here is jquery code what I tried

$("#idUploadFile").val($("#filePathHdnID").val());

Please share me your ideas, sorry if it is confused.

Rajasekhar
  • 2,215
  • 3
  • 23
  • 38
  • I think you can set the value but would be of no use . As when you select any file by `type=file` then it captures the path as well . But here assigning just the value won't work . – Tushar Raj Jan 29 '15 at 06:32

2 Answers2

1

Looking at your requirement, you want to set a default file path for the file input control. Unfortunately, this is a very common requirement that every client wants, but not possible using javascript because of Security Reasons.

What if possible: You as a developer can modify the file input and post it to server, and the actual user will not get notified. Any feature/requirement of language that creates a security threat is kept closed for developers :)

Vijay
  • 2,965
  • 1
  • 15
  • 24
0

You cannot change the value of file input. Because file object created once you has a file selected, and

File object that contain useful information about the file.

name The file's name as a read-only string. This is just the file name, and does not include any path information.

here the file name is the value you want to change.

doc

huan feng
  • 7,307
  • 2
  • 32
  • 56