Home > front end >  How to monitor the HTTP upload progress
How to monitor the HTTP upload progress

Time:12-02

I know through XHR upload a file, it is a onprogress events, can listen to upload progress,

But I'm the current through the server program to simulate HTTP requests, so I want to know how to upload progress?

Now my environment is: nodejs, the code is below, I use HTTP request for file upload, but do not know from which to get progress, since can achieve XHR, do nodejs cannot be achieved? If you provide another plug-in, please let us know, in fact I want to know the principle of upload progress thanks!

 let c=HTTP request (" http://syfosy.com/t.php ", {
Method: "POST",
Headers: {the content-type: "multipart/form - data; A boundary=gc0p4Jq0M2Yt08j34c0p "}
}, res=& gt; {
The console. The log (res. StatusMessage)
});
C.o n (" response ", (I)=& gt; {
The console. The log (I)
})
C.w rite (" -- gc0p4Jq0M2Yt08j34c0p \ r \ n ")
C.w rite (" the content - disposition: the form - data; Filename=1. TXT. Name=a \ r \ n ");
C.w rite (" \ r \ n ")
//let r=fs. CreateReadStream (" C:/Users/Administrator/Desktop/zhang SAN/2/y00045625_20190529_2_12 DCM ");
Let r=fs. CreateReadStream (" C:/Users/Administrator/Desktop/zhang SAN/1. JPG ");

R.o n (" readable ", ()=& gt; {
The console. The log (' readable ')
R.r ead ()

})
R.o n (" data ", d=& gt; {
The console. The log (d.l ength)
C.w rite (d)
})
R.o n (" end ", ()=& gt; {
The console. The log (" end ")
C.w rite (" \ r \ n ")
C.w rite (" -- gc0p4Jq0M2Yt08j34c0p - ")
C.e nd ();
})
  • Related