How to get a file back into an input type file field?

Asked

Viewed 2,069 times

4

I have an html form that uploads a file and I can save it to a folder. The problem is that now I need to do the reverse operation, and return the file in this same input type file field so that the user can edit. Someone can give me a hand, I will be grateful. I have tried to save in the value of this input and still will not.

  • 1

    I’ve never seen anything like it. I’ve tried something like FileReader of Javascript?

  • 1

    You must have saved the file name in some bank or file, in order to recover and put the name back in the input.

  • I’ve tried it this way, but it still won’t come back. I can write what comes from the database on the screen, but not in a File input, just text.

1 answer

6


Is not possible set the value of a input type="file" for security reasons.
Of W3schools:

Note: This Property is read-only, because of security reasons.

An alternative is to put a link to the file near the input with the title "Current file", for example. If it is an image, you could display that image and put the label of input as "Change image".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.