Skip to content

Instantly share code, notes, and snippets.

@DZuz14
Created June 9, 2021 18:39
Show Gist options
  • Save DZuz14/4595b77b65676d0a17b7cab1258ffdcb to your computer and use it in GitHub Desktop.
Save DZuz14/4595b77b65676d0a17b7cab1258ffdcb to your computer and use it in GitHub Desktop.
useFileUpload1
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