Tracking progress of file upload in multer nodejs

前端 未结 4 1389
野趣味
野趣味 2021-02-15 17:01

How to track progress of a file getting uploaded to NodeJs server .I am using multer in server side to upload files. ?

Do i need to send some kind of information to the

4条回答
  •  伪装坚强ぢ
    2021-02-15 17:58

    React Frontend

    const formData = new FormData();
    formData.append('myImage', this.state.imageData);
    const config = {
        onUploadProgress: progressEvent => console.log(progressEvent.loaded), // TO SHOW UPLOAD STATUS
        headers: {
            'content-type': 'multipart/form-data'
        }
    };
    axios.post("/api/api/save-media", formData, config)
        .then((response) => {
            // do whatever you want
        }).catch((error) => {
            console.log(error)
        });
    

提交回复
热议问题