0

I am trying to set a pre-defined value for FILE name. I have added a 'value' tag with 'FILE NAME' , but its not showing any value in the form. Kindly guide me.

<form action= 'fileTesting.php' method= 'POST' >
<input type='file' name= 'image' value='c:/'  />
Name :<input type='name' name='name' value='Name' />
<input type='submit' value='submit'  />

</form>
Community
  • 1
  • 1
Taha Kirmani
  • 1,274
  • 6
  • 26
  • 55
  • possible duplicate of [How to set a value to a file input in HTML?](http://stackoverflow.com/questions/1696877/how-to-set-a-value-to-a-file-input-in-html) – rink.attendant.6 Aug 22 '13 at 05:35
  • 1
    You want to read this: http://stackoverflow.com/questions/20537696/remember-and-repopulate-file-input/20537822#20537822 –  Oct 16 '14 at 07:38

2 Answers2

2

There are security restrictions on inputs of type file, they are read-only. Checkout here http://msdn.microsoft.com/en-us/library/ms535128.aspx

Vivek
  • 147
  • 1
  • 7
1

I doubt it possible. I guess this is for security reasons.

You might consider following scenario: fill the value with a file (password file for instance) and automatically submit a form using JavaScript

Allowing it to set the file would allow uploading any file from the client to your server without any user interaction. Even without notice it if Ajax is used.

i100
  • 4,529
  • 1
  • 22
  • 20
  • When I try to update a product, it shows me empty 'file' field, and I have to re-upload the file in update page. I just want the file name to be written there when user goes to update page. – Taha Kirmani Aug 22 '13 at 05:49
  • there are numerous solutions... one jumping in my mind is to attach handler to onchange event that will upload the file when one have been chosen. Another one is to update whatever you need via Ajax. – i100 Aug 22 '13 at 06:18