-1

this is the HTML code

<input type="file" name="event_image" class="form-control ChangeEvntImage UploadEventImage tab5-required-check" value="<?=$v_image['image']?>">

This is my output:

This is my output

I want this:

I want this

sectus
  • 15,605
  • 5
  • 55
  • 97
Santanu Adak
  • 51
  • 1
  • 6
  • did you check the value for $v_image['image'] ? – Santhosh Kumar Feb 21 '19 at 11:20
  • 1
    What if you do `value="">` – executable Feb 21 '19 at 11:20
  • i want to show my image name when i go for update it, Please look into the last image – Santanu Adak Feb 21 '19 at 11:24
  • like 'no file chosen' to my file name – Santanu Adak Feb 21 '19 at 11:27
  • 1
    What does `$v_image['image']` contain? You want to show the file name before you upload? (Not possible in PHP, need to use Javascript for this) – brombeer Feb 21 '19 at 11:30
  • Possible duplicate of https://stackoverflow.com/questions/1696877/how-to-set-a-value-to-a-file-input-in-html – 04FS Feb 21 '19 at 11:31
  • Apart from that you can’t do it, it would make rather little sense as well - because then the user would upload the same file _again_ (provided it even still exists in the same location in their local file system) once they submitted this form - which is unnecessary to begin with, if they don’t want to _change_ what they have already uploaded. – 04FS Feb 21 '19 at 11:33
  • 1
    use jquery onchange function to show the filename... – Habib Feb 21 '19 at 11:39

2 Answers2

2

You are not able to set a value of HTML File input because of security reason.
Please, check the answer of the older Stackoverflow post: link

Dadinho
  • 57
  • 7
0

As @kerbholz said you have to write javascript.May be this code help you to solve the your problem.

HTML

<!DOCTYPE html>
<html>
<head>
<link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<meta charset=utf-8 />

</head>
<body>
      <input id="image" type="file" name="event_image" class="form-control ChangeEvntImage UploadEventImage tab5-required-check" value="<?=$v_image['image']?> ">
</body>
</html>

SCRIPT

   function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#image')
                    .attr('src', e.target.result)
                    .width(150)
                    .height(200);
            };

            reader.readAsDataURL(input.files[0]);
        }
    }
Rika
  • 333
  • 2
  • 5
  • 19