Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오원석
/
StarCraft2 Build Recommendation
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
임에딘
2018-12-11 00:02:19 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a01cd71c9607a83fa18a1c7a5b19f6623fe11c00
a01cd71c
1 parent
15a303a6
add nodejs_fileupload.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
nodejs_fileupload.js
nodejs_fileupload.js
0 → 100644
View file @
a01cd71
var
http
=
require
(
'http'
);
var
formidable
=
require
(
'formidable'
);
var
fs
=
require
(
'fs'
);
http
.
createServer
(
function
(
req
,
res
){
if
(
req
.
url
==
'/fileupload'
){
var
form
=
new
formidable
.
IncomingForm
();
form
.
parse
(
req
,
function
(
err
,
fields
,
files
){
var
oldpath
=
fiels
.
filetoupload
.
path
;
var
new
path
=
'C:/Users/njs04/'
+
file
.
filetoupload
.
name
;
fs
.
rename
(
oldpath
,
newpath
,
function
(
err
){
if
(
err
)
throw
err
;
res
.
write
(
'File uploaded'
);
res
.
end
();
});
});
}
else
{
res
.
writeHead
(
200
,{
'Content-Type'
:
'text/html'
});
res
.
write
(
'<form action="fileupload" method="post" enctype="multipart/form-data">'
);
res
.
write
(
'<input type="file" name="firetoupload"><br>'
);
res
.
write
(
'<input type="submit">'
);
res
.
write
(
'</form>'
);
return
res
.
end
();
}
}).
listen
(
8080
);
Please
register
or
login
to post a comment