我有这个事件(使用上传图像文件<input type="file">):
"change .logoBusinessBig-upload":function(event, template){
var reader = new FileReader()
reader.addEventListener("load", function(evt){
var x = reader.result
console.log(x)
Meteor.call("saveFile", x)
})
reader.readAsArrayBuffer(event.currentTarget.files[0])
}
Run Code Online (Sandbox Code Playgroud)
而这个Meteor.method()
saveFile:function(file){
console.log(file)
var fs = Npm.require("fs")
fs.writeFile('../../../../../public/jow.txt', file, function (err) {
console.log("file saved")
});
}
Run Code Online (Sandbox Code Playgroud)
事件中的console.log(x)输出一个ArrayBuffer对象,而Meteor.method()中的console.log(文件)显示并清空{}对象.
这是为什么?ArrayBuffer应该已经传递给Meteor.method()
我有这两个控制台日志,但它们返回不同的时间(-2小时关闭).
console.log(new Date()) // Date 2015-04-20T15:37:23.000Z
console.log(Date()) // "Mon Apr 20 2015 17:37:23 GMT+0200 (CEST)"
Run Code Online (Sandbox Code Playgroud)
我知道使用Data()与使用构造函数和调用.toString()相同.
但是,我确实需要Date()时间而不是新的Date()时间.那么为什么它会返回错误的时间,如何重置它以输出正确的时间呢?
谢谢,
我正在寻找获得“明天”的方法从接收到日期的函数返回”和“后天”:
当前日期:
《2015/04/24 18:15:00》
未来的日期:
“2015/04/25 02:40:00”
该函数应在此处返回“明天”。我尝试查找一些函数,但它们都返回 0 而不是 1。
function days_between(date1, date2) {
// The number of milliseconds in one day
var ONE_DAY = 1000 * 60 * 60 * 24
// Convert both dates to milliseconds
var date1_ms = date1.getTime()
var date2_ms = date2.getTime()
// Calculate the difference in milliseconds
var difference_ms = Math.abs(date1_ms - date2_ms)
// Convert back to days and return
return Math.round(difference_ms/ONE_DAY)
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在编写一个角度应用程序,我正在尝试使用该$http服务连接到我们的API .
$http.post('https://backend-test/***/v001/login', {'userName': 'admin', 'password': 'passtest'}, {headers: {'Accept': 'application/json', 'Content-Type': 'application/json'}}).then(function success(response) {
console.log(response);
});
Run Code Online (Sandbox Code Playgroud)
但是,我继续收到此错误:
XMLHttpRequest无法加载 https:// backend-test /***/v001/login.预检的响应具有无效的HTTP状态代码403
它似乎发送OPTIONS请求而不是POST请求:
请求方法:选项
奇怪的是,当我使用这个工具时它正常工作:
有什么想法吗?
date ×2
javascript ×2
angularjs ×1
cors ×1
filereader ×1
fs ×1
http-headers ×1
meteor ×1
node.js ×1
post ×1
time ×1