Solution 1 :

Problem is here:

<button id="file" onClick="document.getElementsById('file').click(); return false;">Upload Photo</button>

It is document.getElementById not document.getIdByElement

Here is working code

<div>
   <input type="file" id="file" style="visibility:hidden"   accept="image/*" capture="camera" />
   <label for="file"></label>
   <button id="file" onClick="document.getElementById('file').click(); return false;">Upload Photo</button>
 </div>

Problem :

Hi guys I’m very new to coding(esp HTML5). I wanted to replace the text inside the “Choose File” button to “Upload Picture”. I referred to some sources and I followed the steps in it, and I was able to change the text(Source: https://www.youtube.com/watch?v=aKDvfxiZ4Zw). The idea is basically hiding the “Choose File” button and replacing it with “Upload Picture” . But when I tested it out, there were no windows that popped out to let me choose file from, i clicked and clicked but nothing came out. And below is the code I referred.

 <div>
   <input type="file" id="file" style="visibility:hidden" accept="image/*" capture="user" />
   <label for="file"></label>
   <button id="file" onClick="document.getIdByElement('file').click(); return false;">Upload Photo</button>
 </div>

Thank you so much in advance and I’m sorry if there’s any confusion but I hope I could get some advices here.

Comments

Comment posted by VentusZXC

Thank you! It’s working! But now I have a another problem, because this will be incorporated in a mobile app, so i tried launching it but nothing came out. But if i were to use Chrome to try to tap on the Upload Photo it works like a charm. What’s the problem here?

Comment posted by Sudarshan Rai

@VentusZXC can you please try now , I removed accept=”image/*” so now it should open file explorer

Comment posted by VentusZXC

Yeah I tried, it works, it opens file explorer. But it is not working on my mobile phone…

Comment posted by Sudarshan Rai

Is your phone android or ios , it should have worked

Comment posted by VentusZXC

My phone is Android, running on Android 10. Yes it works on Android web browser, which is Chrome. Because I have an app which does the same thing, it just doesnt work on the app… So sorry for much trouble but it’s been bugging me quite sometime as a beginner

By