missing file upload input/button
See original GitHub issueCould not find a way to present an upload file button/input using the components provided here (great library btw!)
I’ve been using this and it seems to work well, perhaps a cleaner version could be included:
function UploadButton({label, onUpload, id}) {
let fileInput = null;
// If no id was specified, generate a random one
const uid = id || Math.random().toString(36).substring(7);
return (
<span>
<label htmlFor={uid} className="ui icon button">
<i className="upload icon"></i>
{label}
</label>
<input type="file" id={uid}
style={{display: "none"}}
onChange={() => {
onUpload(fileInput.files[0]);
}}
ref={input => {
fileInput = input;
}}
/>
</span>
);
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:17
- Comments:18 (4 by maintainers)
Top Results From Across the Web
input type=file show only button
The with "Upload File" text pushes the input control out of view in the wrapper div when it overflows so there is no...
Read more >"input type=file". File name disappears if there is a post-back
Hi, I have <input type=file runat=server> control on my web page. Once I click the browse button and locate a file, the file...
Read more ><input type="file"> - HTML: HyperText Markup Language | MDN
A file input's value attribute contains a string that represents the path to the selected file(s). If no file is selected yet, ...
Read more >File Upload Button is missing
I installed the plugin but when I click on the PDF Form button in the CF7 form, the pop-up windows does not have...
Read more >Missing File Upload Button
It seems to be a glitch so I have recreated the file upload field in your form. This fixes it. Could you please...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think a file button is a bit too specific, the idea you’ve used is a solution.
@strrel try this one The original is a typescript snippet