stanjdev / realyzer

A web application for real estate investors to determine a rental property's profitability (ROI). Creates a printable PDF report with images and a map of the property
https://realyzer.app/
5 stars 1 forks source link

input file type lastly for use to upload their own logo #2

Closed stanjdev closed 4 years ago

stanjdev commented 4 years ago

<input type="file"/>

https://reactjs.org/docs/forms.html "file input tag"

stanjdev commented 4 years ago
File is saved here: event.target.files[0] -- use this in onFileChange function

           <input 
                  name="logo"
                  type="file"
                  onChange={onFileChange}
                />

            <div>
              {globalState.logo ? <img src={URL.createObjectURL(globalState.logo)} height="175" onLoad={URL.revokeObjectURL(this)}/> : null}
            </div>

Upload and the manipulate the file or image using File API: https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications

https://www.geeksforgeeks.org/file-uploading-in-react-js/

https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL