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"? 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"? 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.

Sign up to request clarification or add additional context in comments.

2 Comments

It's perfect! Thanks!
You're always welcome dude.
-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 Comments

The OP intends to use the input type file. Changing type would not help
Please clarify your answer first try your solution then tell complete and clear answer to get the up vote.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.