0

I have a button for upload image in html:

<input id="album-image-input" style="display:none;" type="file" name="albumimages" multiple  onchange="previewImages(this.files)"  maxlength="10" accept="image/png,image/jpg"/>
<button  onclick="HandleBrowseClick('album-image-input');" >UPLOAD IMAGE</button>

with js:

function HandleBrowseClick(input_image){
    var fileinput = document.getElementById(input_image);
    fileinput.click();
} 

At certain pages when I click on the UPLOAD IMAGE, it will call:

Navigated to http://localhost:8888/mysite/?albumimages=

but not at some pages.

Why is that? And how can I prevent that from happen?

sooon
  • 4,718
  • 8
  • 63
  • 116

1 Answers1

0

Due to security concerns, you generally aren't allowed to programmatically click an input[type=file] button. In some cases, depending on if the button is visible, you may be allowed. Yours is unlikely to work because the button is hidden. For more information, see this question.

Community
  • 1
  • 1
Michael Sacket
  • 897
  • 8
  • 13