Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get image url in react input file or preview form image

getInitialState: function(){
  return{file: []}
}

_onChange: (event)=>{
    this.setState({
        imgs: event.target.files
    })
},

render: function(){
 return(
  <div>
    <form>
      <input 
        ref="file" 
        type="file" 
        name="user[image]" 
        multiple="true"
        onChange={this._onChange}/>
    </form>

    {/* Display all selected images. */}        
    {this.state.imgs && [...this.state.imgs].map((file)=>(
       <img src={URL.createObjectURL(file)} />
    ))}

  </div>
 )
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: scroll to top in jquery 
Javascript :: floating point in javascript 
Javascript :: sweetalert angular 8 
Javascript :: how to store array into react-native local storage 
Javascript :: adonis attach 
Javascript :: javascript create uuid 
Javascript :: js toisostring 
Javascript :: jsconfig.json vue 
Javascript :: get attribute href 
Javascript :: how to define emojis from your server in discord.js 
Javascript :: javascript object total 
Javascript :: Check if local storage is used or empty 
Javascript :: redirect using javascript 
Javascript :: redirect user to another page javascript 
Javascript :: click listener on by class name in javascript 
Javascript :: How to Get the First n Characters of a String in javascript 
Javascript :: cypress set viewport for all test cases 
Javascript :: javascript regex escape forward slash 
Javascript :: how to show only time in hours and minutes only in javascript 
Javascript :: get random letter js 
Javascript :: pick random from array 
Javascript :: js functions inside of objects 
Javascript :: js get all query string 
Javascript :: push element to array to first place js 
Javascript :: Jquery search in json 
Javascript :: loopback upsert with where 
Javascript :: how to get xhr response in javascript 
Javascript :: useffect compare previous value to current 
Javascript :: html video autoplay not working 
Javascript :: vue get props into data 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =