1

I'm trying to change the text value of the input button of type file. I know it is the parameter value='' but in this case it is not working.

My code:

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link href="assets/css/custom-sugar-style.css" rel="stylesheet">
<div class="container-fluid">
  <div class="row">
    <div class="col-md-12 text-center">
      <img class="img-sugar" src="assets/images/SUGAR.png" />
      <br>
      <br>
      <br>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12 text-center">
      <form action="shareimage.php" method="post">
        <input class="button-camera" type="file" accept="image/*" capture="camera" value="Take a photo" />
      </form>
    </div>
  </div>

Could you help me?

Thanks!

3
  • 1
    what do you mean saying "doesn't work fine"?
    – lomboboo
    Commented Nov 17, 2016 at 12:03
  • Check this post here. This might help. Commented Nov 17, 2016 at 12:09
  • Do you mean placeholder="Something that appears inside the input field until text is entered by a user"?
    – Joshua
    Commented Nov 17, 2016 at 12:11

2 Answers 2

2
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function HandleBrowseClick()
 {
var fileinput = document.getElementById("browse");
fileinput.click();
 }
function Handlechange()
 {
 var fileinput = document.getElementById("browse");
  var textinput = document.getElementById("filename");
  textinput.value = fileinput.value;
  }
</script>

 <input type="file" id="browse" name="fileupload" style="display: none"    onChange="Handlechange();"/>

 <input type="button" value="Take a photo" id="fakeBrowse"    onclick="HandleBrowseClick();"/>No file chosen
</body>
</html>

Try this technique and apply your css class in it.

2
  • It's perfect! Thanks!
    – ruzD
    Commented Nov 17, 2016 at 12:35
  • You're always welcome dude.
    – user5093161
    Commented Nov 17, 2016 at 12:36
-3

You are using the input type file that's why you can not change the value.

<input class="button-camera" type="file" accept="image/*" capture="camera" value="Take a photo" />

change type

<input class="button-camera" type="Button" accept="image/*" capture="camera" value="Take a photo" />
2
  • The OP intends to use the input type file. Changing type would not help Commented Nov 17, 2016 at 12:15
  • Please clarify your answer first try your solution then tell complete and clear answer to get the up vote.
    – user5093161
    Commented Nov 17, 2016 at 13:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.