【发布时间】:2015-05-12 08:32:47
【问题描述】:
我将 Lotus Notes 表单用作 .html 文件,并使用 Angular js 将值作为 json 发送到服务器。但我现在也想上传文件。如何使用 lotus 脚本将文件发送到服务器并提取?
你能帮帮我吗?
喜欢下面的帖子。但它是在 ASP.NET 中完成的。我想用莲花笔记做同样的事情。
File uploading angular js ASP .NET
index.html
<span ng-if="quests.type == '17'">
<input type="file" file-upload multiple id='{{quests.id}}'/>
</span>
<button type="button" ng-click="submitForm();">Submit</button>
上面的按钮会触发下面的代码执行。
要发布到服务器的 Angular 代码
var email=document.getElementById("email").value;
var message={"requesttype": "saveForm","email": emailid,"username": username};
$http.post("http://test.com/ajaxprocess?openagent", message).success(success).error(failure);
上面提到的agent(lotusscript)会解析上面的json并保存文档,如下图。
ajaxprocess 代理代码
'getting document context
Set docContext = sess.DocumentContext
If docContext.hasItem("REQUEST_CONTENT") Or docContext.hasItem("REQUEST_CONTENT_000") Then
'using openNTF lotus script classes to parse document to json object
Set userDataInfo=getJSONObjectFromDocument(docContext, "")
Dim fieldsobj As New JSONArray
'getting the fields array sent as json array
Set fieldsobj=userDataInfo.GetItemValue("fields")
fieldtype=Field.mGetItemValue("type")(0)
Dim doc As NotesDocument
Dim fieldname As String
ForAll Field In fieldsobj.Items
fieldname=Field.mGetItemValue("Fieldname")(0)
Call doc.Replaceitemvalue(fieldname,Field.mGetItemValue("value")(0))
End ForAll
call doc.save(true,false)
End If
除了文件附件,一切正常。如何使用 json 将文件发送到服务器并使用 lotus 脚本保存或是否有其他解决方法?
【问题讨论】:
-
你试过什么?向我们展示你编写的代码来尝试这个并告诉你发生了什么。
-
嗨,理查德,感谢您的回复。我已经编辑了帖子。请看一看。
-
您的 Angular 代码引用了一个名为 ajaxprocess 的代理。那个代理在哪里?显示您尝试过的源代码。
-
我已经在上面发布了服务器代码。现在我正在发送所有字段类型(文本、日期、时间)并能够保存文档。但是我无法使用上面的代码实现文件上传,因为我不知道上传和解码附件的方法。如果不清楚,请告诉我。感谢您宝贵的时间帮助我。非常感谢。
-
恐怕我无法帮助您使用 angular.js 在浏览器端做些什么。我确实知道,如果您想实际存储它以便 Domino 将其视为附件,您将不得不在您的 LotusScript 代码中进行更多处理 - 但如果它甚至没有为您上传,那是不相关的。我已经对这个问题投了赞成票,也许知道 Angular 的人可以提供帮助。
标签: json angularjs file-upload lotus-notes lotusscript