Last active
March 25, 2021 17:03
-
-
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
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 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; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find the tutorial here: https://ethanbon.com/blog/uploading-cropped-profile-images-to-digital-ocean-spaces-1