Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

multiple image upload in react js

import * as React from "react"

class ImageUpload extends React.Component {
  state: {
    files: []
  }

  fileSelectedHandler = (file: any) => {
    let addedFiles = this.state.files.concat(file)
    this.setState({ files: addedFiles })
    console.log("upload file " + file.name)
  }

  render() {
    return (
      < form >
        <div>
          <h2>Upload images</h2>
        </div>
        <h3>Images</h3>
        <input type="file" onChange={this.fileSelectedHandler} />
      </form>
    )
  }
}

export default ImageUpload
Comment

multiple image upload react

class ImageUpload extends React.Component {
  state = {
    files: []
  }

  fileSelectedHandler = (e) => {
    this.setState({ files: [...this.state.files, ...e.target.files] })
  }

  render() {
    return (
      <form>
        <div><h2>Upload images</h2></div>
        <h3>Images</h3>
        <input type="file" multiple onChange={this.fileSelectedHandler} />
      </form>
    )
  }
}


ReactDOM.render(<ImageUpload />, document.getElementById('app'))
Comment

PREVIOUS NEXT
Code Example
Javascript :: redux saga fetch api 
Javascript :: jquery function return 
Javascript :: react chart.js 
Javascript :: if statement in react native 
Javascript :: vue is undefined vue 3 vue.use 
Javascript :: js reduce method 
Javascript :: chart js donut 
Javascript :: react native flex 2 columns per row 
Javascript :: date format in jquery 
Javascript :: convert array to csv javascript 
Javascript :: nodejs sql syntax 
Javascript :: js base64 encode 
Javascript :: checkbox react 
Javascript :: jquery filtering 
Javascript :: javascript first letter uppercase 
Javascript :: vue component lifecycle 
Javascript :: flatlist only rendering 10 items 
Javascript :: how to use json stringify in javascript 
Javascript :: javascript check if string ends with space 
Javascript :: jquery validation from data 
Javascript :: how to sort array least to greatest javascript stACK 
Javascript :: how to remove first element from array in javascript 
Javascript :: filter in javascript 
Javascript :: create an empty array js 
Javascript :: how to turn decimales into percents with javascript 
Javascript :: js get first and last day of previous month 
Javascript :: javascript wait for function to finish 
Javascript :: javascript string new line 
Javascript :: closest js 
Javascript :: query string to object javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =