How to use attr-accept - 10 common examples

To help you get started, we’ve selected a few attr-accept examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jolocom / smartwallet-app / src / js / components / node / add-generic-old.jsx View on Github external
this.state.fileArray.pop()
      }
      this.setState({
        hasImages: true
      })
      this.state.tagArray = []
      this.state.tagArray.push({
        key: 1,
        label: 'Image'
      })
      this.setState(this.state)
      // Checks for documents
    } else if (accepts(file, '.txt') || (accepts(file, '.docx')) ||
      accepts(file, '.odt') || accepts(file, '.pages') ||
      accepts(file, '.pdf') || accepts(file, '.pptx') ||
      accepts(file, '.keynote') || accepts(file, '.doc') ||
      accepts(file, '.odp') || accepts(file, '.ppt') ||
      accepts(file, '.ods') || accepts(file, '.xlsx') ||
      accepts(file, '.xls') || accepts(file, '.html')) {
      this.setState({
        uploadedFileType: 'document'
      })
      // USING 1 FILE INSTEAD OF MULTIPLE UPLOAD CAPABILITIES

      this.state.docArray[0] = {
        file: file,
        key: this.state.docArray.length + 1,
        uri: this.state.uploadedFileUri
      }
      if (this.state.imgArray[0]) {
        this.state.imgArray.pop()
      }
github jolocom / smartwallet-app / src / js / components / node / add-generic-old.jsx View on Github external
}
      if (this.state.fileArray[0]) {
        this.state.fileArray.pop()
      }
      this.setState({
        hasImages: true
      })
      this.state.tagArray = []
      this.state.tagArray.push({
        key: 1,
        label: 'Image'
      })
      this.setState(this.state)
      // Checks for documents
    } else if (accepts(file, '.txt') || (accepts(file, '.docx')) ||
      accepts(file, '.odt') || accepts(file, '.pages') ||
      accepts(file, '.pdf') || accepts(file, '.pptx') ||
      accepts(file, '.keynote') || accepts(file, '.doc') ||
      accepts(file, '.odp') || accepts(file, '.ppt') ||
      accepts(file, '.ods') || accepts(file, '.xlsx') ||
      accepts(file, '.xls') || accepts(file, '.html')) {
      this.setState({
        uploadedFileType: 'document'
      })
      // USING 1 FILE INSTEAD OF MULTIPLE UPLOAD CAPABILITIES

      this.state.docArray[0] = {
        file: file,
        key: this.state.docArray.length + 1,
        uri: this.state.uploadedFileUri
      }
      if (this.state.imgArray[0]) {
github sanity-io / sanity / packages / @sanity / components / src / fileinput / DropZone.js View on Github external
        acceptsSelectedFiles: Array.from(items).every(item => accepts(item, accept))
      })
github sanity-io / sanity / packages / @sanity / form-builder / src / sanity / uploads / resolveUploader.ts View on Github external
return uploaders.find(uploader => {
    return (
      is.type(uploader.type, type) &&
      accept(file, uploader.accepts) &&
      accept(file, get(type.options, 'accept') || '')
    )
  })
}
github jolocom / smartwallet-app / src / js / components / accounts / profile.jsx View on Github external
_handleSelectPassportFile({target}) {
    let gAgent = new GraphAgent()
    let file = target.files[0]
    if (!accepts(file, 'image/*')) {
      this.setState({
        error: 'Invalid file type'
      })
    } else {
      this.setState({
        loadingPassportPhoto: true
      })
      this.setState({
        error: null,
        passportFile: file
      })
      gAgent.storeFile(null, this.state.storage, file, true).then((res) => {
        this.setState({
          loadingPassportPhoto: false
        })
        this.setState({passportImgUri: res})
github jolocom / smartwallet-app / src / js / components / accounts / profile.jsx View on Github external
_handleSelectFile({target}) {
    let file = target.files[0]
    if (!accepts(file, 'image/*')) {
      this.setState({
        error: 'Invalid file type'
      })
    } else {
      this.setState({
        loadingDisplayPhoto: true
      })
      this.setState({
        error: null,
        file: file
      })
    }
  },
github sanity-io / sanity / packages / @sanity / form-builder / src / sanity / uploads / resolveUploader.ts View on Github external
return uploaders.find(uploader => {
    return (
      is.type(uploader.type, type) &&
      accept(file, uploader.accepts) &&
      accept(file, get(type.options, 'accept') || '')
    )
  })
}
github jolocom / smartwallet-app / src / js / components / node / add-generic.jsx View on Github external
_handleFileUpload({target}) {
    if (this.state.uploadedFile) {
      this._handleRemoveFile()
    }
    const file = target.files[0]
    this.setState({
      uploadedFile: file
    })
    if (accepts(file, 'image/*')) {
      this.setState({
        uploadedFileType: 'image'
      })
      this._handleImagePreview(file)
    } else if (accepts(file, '.txt') || (accepts(file, '.docx')) ||
      accepts(file, '.odt') || accepts(file, '.pages') ||
      accepts(file, '.pdf') || accepts(file, '.pptx') ||
      accepts(file, '.keynote') || accepts(file, '.doc') ||
      accepts(file, '.odp') || accepts(file, '.ppt') ||
      accepts(file, '.ods') || accepts(file, '.xlsx') ||
      accepts(file, '.xls') || accepts(file, '.html')) {
      this.setState({
        uploadedFileType: 'document'
      })
    } else {
      this.setState({
        uploadedFileType: 'miscFile'
      })
    }
    this._autofillWithFilename(file)
  },
github react-dropzone / react-dropzone / src / utils / index.js View on Github external
export function fileAccepted(file, accept) {
  return file.type === 'application/x-moz-file' || accepts(file, accept)
}
github opennode / waldur-homeport / app / scripts / components / form-react / FileUploadField.tsx View on Github external
handleFile = event => {
    const files = event.target.files;
    if (files.length === 1) {
      const file = files[0];
      if (!this.props.accept || accepts({
        type: file.type,
        name: file.name,
      }, this.props.accept)) {
        this.setState({fileName: file.name});
        this.props.input.onChange(file);
        return;
      }
    }
    this.setState({fileName: undefined});
    this.props.input.onChange(null);
  }

attr-accept

JavaScript implementation of the "accept" attribute for HTML5 <input type="file">

MIT
Latest version published 14 days ago

Package Health Score

92 / 100
Full package analysis

Popular attr-accept functions