File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
- <!-- code by navnee1h -->
2
1
<!DOCTYPE html>
3
2
< html >
4
3
< head >
5
- < title > Upload Your Files /title>
4
+ < title > File Upload with Progress and Speed < /title >
6
5
< style >
7
6
body {
8
7
font-family : Arial, sans-serif;
@@ -158,14 +157,15 @@ <h2>Upload Multiple Files</h2>
158
157
const percentComplete = ( event . loaded / event . total ) * 100 ;
159
158
progressBar . value = percentComplete ;
160
159
161
- const elapsedTime = ( Date . now ( ) - startTime ) / 1000 ; // time in seconds
162
- const speed = ( event . loaded / elapsedTime ) / ( 1024 * 1024 ) ; // speed in MB/s
160
+ const elapsedTime = ( Date . now ( ) - startTime ) / 1000 ; // Time in seconds
161
+ const speed = ( event . loaded / elapsedTime ) / ( 1024 * 1024 ) ; // Speed in MB/s
163
162
status . textContent = `Transferred: ${ Math . round ( event . loaded / ( 1024 * 1024 ) ) } MB /
164
163
${ Math . round ( event . total / ( 1024 * 1024 ) ) } MB
165
164
(${ percentComplete . toFixed ( 2 ) } %) at ${ speed . toFixed ( 2 ) } MB/s` ;
166
165
}
167
166
} ;
168
167
168
+ // Reset progress bar and display success message upon completion
169
169
xhr . onload = function ( ) {
170
170
if ( xhr . status === 200 ) {
171
171
alert ( 'Files uploaded successfully!' ) ;
@@ -190,4 +190,3 @@ <h2>Upload Multiple Files</h2>
190
190
</ script >
191
191
</ body >
192
192
</ html >
193
- <!-- code by navnee1h -->
You can’t perform that action at this time.
0 commit comments