var http = require('http');
var fs = require('fs').createWriteStream('file1');;
http.createServer(function(req, res) {
// This opens up the writeable stream to `output`
// This pipes the POST data to the file
req.pipe(fs);
// After all the data is saved, respond with a simple html form so they can post more data
req.on('end', function() {
res.writeHead(200, {"content-type":"text/html"});
res.end('<form method="POST"><input name="test" /><input type="submit"></form>');
});
// This is here incase any errors occur
fs.on('error', function (err) {
console.log(err);
});
}).listen(8080);
위의 코드에서 POST 메서드를 사용하여 HTML 양식의 입력을 받아들이고 파일의 쓰기 스트림에 파이프를 삽입하려고합니다. 그러나이를 달성 할 수는 없습니다. 다음 오류가 표시됩니다.NODEJS writeStream 오류
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
{ [Error: EBADF, close] errno: 9, code: 'EBADF' }
뭐가 잘못 되었나요? 내가 POST에서 파일로 데이터를 성공적으로 리디렉션 할 수 있도록하려면 어떻게해야합니까 ?? 나는이 관련 포스트 Node.js EBADF error when writing file using writable stream
을 읽을 수는 있지만 여전히있는 방법, 나는 NODEJS의 안돼서 찾을 수 couldnt는 당신이 ...