Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sweetalert2

// reactjs codeto browse and upload an image from your device  
const addImage =async() => {

    const { value: file } = await Swal.fire({
      title: 'Select image',
      input: 'file',
      inputAttributes: {
        'accept': 'image/*',
        'aria-label': 'Upload your profile picture'
      }
    })
    
    if (file) {
      const reader = new FileReader()
      reader.onload = (e) => {
        Swal.fire({
          title: 'Your uploaded picture',
          imageUrl: e.target.result,
          imageAlt: 'The uploaded picture'
        }
        
        )
        console.log(e.target.result);
      }
     
      reader.readAsDataURL(file)
    }
    
Source by sweetalert2.github.io #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
5+9 =