Skip to content

Instantly share code, notes, and snippets.

@EthanBonsignori
Last active March 25, 2021 17:03
Show Gist options
  • Select an option

  • Save EthanBonsignori/5794af1e9c9716f261ae9eaa96b9cf16 to your computer and use it in GitHub Desktop.

Select an option

Save EthanBonsignori/5794af1e9c9716f261ae9eaa96b9cf16 to your computer and use it in GitHub Desktop.
First revision of App.js for the picture upload tutorial: https://ethanbon.com/blog/uploading-user-cropped-profile-images-to-digital-ocean-spaces-1
import React from 'react';
function App() {
// Placeholder, will fetch url from Database when setup
const profilePictureUrl = "https://placehold.it/200x200";
const handleChange = (evt) => {
const file = evt.target.files[0];
console.log(file); // log file for now
};
return (
<div className="App">
<h3>Profile Picture Upload</h3>
<img className="profile-picture" alt="profile" src={profilePictureUrl} />
<label className="upload-label" htmlFor="upload">Change Profile Picture</label>
<input
id="upload"
type="file"
accept="image/*" // Only accept image files (.jpg, .png, .gif, etc)
style={{ display: "none" }}
onChange={handleChange}
/>
</div>
);
};
export default App;
@EthanBonsignori
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment