Guest User

Untitled

a guest
Nov 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <input ref={el => { this.refInput = el }} accept="image/*"
  2. className="viewInputGallery" type="file" onChange={this.onChoosePhoto} />
  3.  
  4. onChoosePhoto = event => {
  5. if (event.target.files && event.target.files[0]) {
  6. this.setState({ isLoading: true })
  7. this.currentPhotoFile = event.target.files[0]
  8. // Check this file is an image?
  9. const prefixFiletype = event.target.files[0].type.toString()
  10. if (prefixFiletype.indexOf(AppString.PREFIX_IMAGE) === 0) {
  11. this.uploadPhoto()
  12. } else {
  13. this.setState({ isLoading: false })
  14. this.props.showToast(0, 'This file is not an image')
  15. }
  16. } else {
  17. this.setState({ isLoading: false })
  18. }
  19. }
Add Comment
Please, Sign In to add comment