1
 <div cssName="row upload-btn-box">
                                <Button
                                  htmlFor="myInput"
                                  component="span"
                                  className="upload-btn"
                                >
                                    {/* <span> <img src={Upload} alt="Upload Certificate" /> </span> */}
                                   Upload  Certificate
                                                        </Button>
                                    <input
                                    id="myInput"
                                    style={{ display: 'none' }}
                                    type={"file"}
                                    onChange={fileSelectedHandler}
                                />
                            </div>

this the code i am using i have seen many stack over flow but nothing is working . where i am doing mistake why the dialog for uploading file is not opening

1 Answer 1

2

You have a htmlFor attribute on a button element when that should be used on a label. If you were to change your code to the following it should work, you can style the label accordingly to appear as a button.

 <div cssName="row upload-btn-box">
   <label
     htmlFor="myInput"
     className="upload-btn"
   >
       Upload  Certificate
   </label>
   <input
     id="myInput"
     style={{ display: 'none' }}
     type={"file"}
     onChange={fileSelectedHandler}
   />
 </div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.