Is it possible to insert value in input type="file"?

Hi,
Can anyone tell me how to insert value in input type=“file” ?
If anyone knows please reply.
Thanks.

No, it is forbidden due to the possible security implications.

Then how to retrieve data from database for an image ?

This is normally done by:

  • Display the image from the database in <IMG> tag
  • Have another file browse field for changing the new one.

Hope you understand what I mean!

That (getting file information for an uploaded file) is possible. When a file is uploaded a superglobal called $_FILES will be populated. It contains information on the file’s size, where it was stored in the tmp file system (you’ll have to move it from there to your database or permanent file system storage), and the mime type.

PHP Manual entry on handling file uploads.

It’s not possible to have the value of file path in your upload form pre-populated.
If it was possible someone could write a form that pre-populates file input with a path to some private file on your computer, then if you don’t notice it an press “submit” it would just grab your file and send it to their server.

And that wouldn’t even be that hard since file architectures are fairly predictable - especially Windows and Mac - Linux less so due to all the distros floating about.