Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

image uploading payload

const onFileChange = (event: any) => {
    {
      !isDocReplace ?
        (
          setUploadPayload({ ...uploadPayload, file: event.target.files[0] })

        ) :
        setReplacePayload({ ...replacePayload, file: event.target.files[0] })  // storing file detail for payload
    }
    setNewFileUploaded(true);
    setFileName(event.target.files[0].name);  // storing name of file in a state
  };

  <input type="file" onChange={onFileChange} id="raised-button-file" style={{ display: "none" }} />
 
PREVIOUS NEXT
Tagged: #image #uploading #payload
ADD COMMENT
Topic
Name
4+6 =