我正在尝试在我在localhost上运行的节点应用中实现ng file upload。我要离开演示here,但是当我将目录更改为
时file.upload = Upload.upload({
url: 'uploadImages',
data: {file: file}
});
我得到了404:
angular.js:10765 POST http://localhost:8888/uploadImages/ 404(未找到)
我是否需要为该目录设置快速路由?我试过了,但它无论是
都没有用app.post('/uploadImages', cors(corsOptions), function(req, res){
res.sendfile('./uploadImages')
});
不确定从哪里开始。
答案 0 :(得分:1)
是的,您需要设置像Node Express服务器这样的Web服务器来接受POST请求。我过去这样做的方法是使用multer,一个Express中间件来处理多部分上传。
示例强>
private void ImagetoBinary(string FileName)
{
byte[] BinaryValue = ImageBinaryConvertion.ImageToBinary(FileName);
lblBinaryValue.Text = "Converted";
Image Image = ImageBinaryConvertion.BinaryToImage(BinaryValue);
pbImage.Image = Image;
}
private void btnImagePath_Click(object sender, EventArgs e)
{
string FileName = "";
OpenFileDialog OpenDig = new OpenFileDialog();
OpenDig.Filter = "All Files (*.*)|*.*";
OpenDig.FilterIndex = 1;
OpenDig.Multiselect = true;
if (OpenDig.ShowDialog() == DialogResult.OK)
{
FileName = OpenDig.FileName;
}
txtImagePath.Text = FileName.ToString();
ImagetoBinary(FileName);
}