Created
June 9, 2021 18:39
-
-
Save DZuz14/4595b77b65676d0a17b7cab1258ffdcb to your computer and use it in GitHub Desktop.
useFileUpload1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef } from 'react' | |
const App = () => { | |
const inputRef = useRef() | |
return ( | |
<div> | |
<h1>Upload Files</h1> | |
<p> | |
Please use the form to your right to upload any file(s) of your | |
choosing. | |
</p> | |
<div className="form-container"> | |
{/* Display the files to be uploaded */} | |
<div> | |
<ul></ul> | |
</div> | |
{/* Provide a drop zone and an alternative button inside it to upload files. */} | |
<div> | |
<p>Drag and drop files here</p> | |
<button onClick={() => inputRef.current.click()}> | |
Or select files to upload | |
</button> | |
{/* Hide the crappy looking default HTML input */} | |
<input | |
ref={inputRef} | |
type="file" | |
multiple | |
style={{ display: 'none' }} | |
/> | |
</div> | |
</div> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment