我如何发送文件,服务器用fs.createwriteStream()读取它;
var http = require('http');
var fs = require('fs');
http.createServer(function(req, res) {
// This opens up the writeable stream to `output`
var writeStream = fs.createWriteStream('./output');
// This pipes the POST data to the file
req.pipe(writeStream);
req.on('end', function () {
res.end('ok upload file');
});
// This is here incase any errors occur
writeStream.on('error', function (err) {
console.log(err);
});
}).listen(8080);
我在console linux中使用此命令: curl --upload-file hello.txt 127.0.0.1:3000并且工作正常,但我不知道如何使用url发送文件
有人知道吗?答案 0 :(得分:-1)
curl -i -F name = test -F filedata =@localfile.jpg 127.0.0.1:3000