【问题标题】:Angular NodeJS FileUpload using client/server paradigmAngular NodeJS FileUpload 使用客户端/服务器范式
【发布时间】:2016-10-15 15:02:56
【问题描述】:

我是一名开发人员,负责将应用程序重写为 Angular、NodeJS、Expressjs 和 Couchbase。我的任务之一是将各种平面文件上传到网络服务器。

在人们说要查看特定问题、git 或 npm 或 jsfiddle 等中的特定链接之前,我已经查看了所有这些网站,但没有找到适合设计开发风格的示例。环境由以下部分组成: 控制器与表示层对话 控制器与客户端服务对话 客户端服务与服务器端控制器对话。

我曾尝试使用 jsfiddle.net 中的 jejenny/zg9re 链接,但遇到了问题。看来她的示例是为客户端处理设置的。 $http.post 发生在客户端。

当我尝试将文件发布到网络服务器时出现问题,我的代码执行如下:

Controller passes the request to client side service
Client side service passes the request to the server side controller
But the client side service is not adding the file to webserver
    I cannot figure out what is the code on the server side controller

我希望找到:

Explanation on how to split code in jsfiddle.net/jejenny/zg9re into client server side request to server side controller.
OR
A web example that perform the code using the client side service passing file to the server side controller to upload to the webserbver

TIA

【问题讨论】:

标签: angularjs node.js express file-upload couchbase


【解决方案1】:

我不知道代码的上传器部分,但绑定不适用于指令,因此文件名永远不会到达该部分。还有其他指令没有这个问题,但你也可以在你的文件输入中添加一个 id,然后在你的控制器中使用:file = document.getElementById("your id").value 来获取文件名。

【讨论】:

  • 感谢您的回答,但我的指令有效,但我遇到的问题是与帖子关联的代码被嵌入为客户端处理。我需要从客户端提取代码并转移到服务器 api 调用。
  • 该指令在 jsfiddle 中不起作用。不完全确定您的意思,您必须发布一个帖子才能将数据发送到服务器。服务端代码是用什么写的?
  • 使用的范式如下:X.html 与 x.controller.js 对话。 x.contoller.js 与 x.service.js 对话(所有 3 个都驻留在客户端) x.service 与 x.controller.js(服务器 API)对话。所有代码都是javascript。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-09
  • 2016-03-19
  • 1970-01-01
  • 2013-02-02
  • 1970-01-01
  • 1970-01-01
  • 2017-03-04
相关资源
最近更新 更多