想要上传 3 个文件的数组,但在我的 nodejs 中,我只从 angular 控制器中得到一个空数组。
在我的角度控制器中,我使用 onchange 方法从 html 获取文件,并将其与 http 请求一起发送到我的 nodejs 后端中的上传功能。
this.selectFile1 = function(files){
fileArray[0] = files[0];
self.files = files;
}
this.selectFile2 = function(files){
fileArray[1] = files[0];
self.files = files;
}
this.selectFile3 = function(files){
fileArray[2]= files[0];
self.files = files;
}
this.upload = function(){
var fd = new FormData();
var file = fileArray;
fd.append('file', file);
$http.post("/upload", fd, {
transformRequest: angular.identity,
headers: {"Content-Type": undefined}
}).then(function success(response){
if(response.status == 200){
console.log('success');
}
}, function error(response){
console.log(response.data.msgUpload);
})
} …Run Code Online (Sandbox Code Playgroud) 我的 db.js 中有 getName 函数
function getName(uid){
db.all("SELECT name FROM table WHERE uid = ? ", function (err){
if(err){
console.log(err);
}else{
console.log(this);
}
});
}
Run Code Online (Sandbox Code Playgroud)
我想获取名称并将其保存到另一个文件中的 var name 。
var uid = req.session.user;
var name = db.getName(uid);
console.log(name);
Run Code Online (Sandbox Code Playgroud)
db 函数 getname 有什么问题为什么我会得到未定义的结果?如果你能帮助我那就太好了!
我尝试生成 RSA CA 密钥对和证书并将其保存到密钥库。我的代码是:
import java.io.FileOutputStream;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.SecureRandom;
import java.security.Security;
import java.security.cert.X509Certificate;
import java.util.Date;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.X509v3CertificateBuilder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
private static final String storeType = "PKCS12";
private static final String storePassword = "password";
private static final String storePath = "/usr/lib/java/keystore.ks";
private static final Date startDate = new Date(System.currentTimeMillis()); // time from which certificate is valid
private static final Date expiryDate = …Run Code Online (Sandbox Code Playgroud) 我已经用 nodejs crypto 创建了一个私钥,并想用这个密钥签署一个文件。我的代码如下:
var ecdh = crypto.createECDH('brainpoolP512t1');
ecdh.generateKeys();
var key = ecdh.getPrivateKey('buffer');
var data= fs.readFileSync(req.file.path);
var sign = crypto.createSign('sha512');
sign.update(data);
var signature = sign.sign(key, 'hex');
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Sign.sign (crypto.js:283:26)
at /....js:32:27
at Immediate.<anonymous> (/.../node_modules/multer/lib/make-middleware.js:52:37)
at runCallback (timers.js:578:20)
at tryOnImmediate (timers.js:554:5)
at processImmediate [as _immediateCallback] (timers.js:533:5)
Run Code Online (Sandbox Code Playgroud)
我知道这与密钥格式有关,但我不知道如何解决这个问题。任何人都可以帮忙吗?
更新:我编辑了私钥以适合 pem 格式:
var KEY_START = '-----BEGIN EC PRIVATE KEY-----\n';
var KEY_END = '\n-----END EC PRIVATE KEY-----';
const ecdh = crypto.createECDH('brainpoolP512t1');
ecdh.generateKeys();
var key =KEY_START …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个运行流畅的滚动文本。该<marquee>..</marquee>标签不无颠簸工作,我不认为这是良好的编程。我想用 JavaScript 来做,但我完全是初学者。
我发现了一些易于理解的代码,但我认为最好看的滚动文本对我来说并不连贯。
也许有人可以向我解释我不明白的部分。
代码:
var marqueewidth="2400px"
var marqueeheight="45px"
var speed=1
var pause=1 //stop by mouseover 0=no. 1=yes
var marqueecontent='<nobr><span style="font-size:40px">*** Wir wünschen einen guten Start in den Dezember!!! ***</span></nobr>'
var newspeed=speed
var pausespeed=(pause==0)? newspeed: 0
document.write('<span id="temp" style="visibility:hidden; position:absolute; top:0px; left:-9000px">'+marqueecontent+'</span>')
var actualwidth=''
var cross_marquee, ns_marquee
function populate(){
cross_marquee= document.getElementById("marquee")
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
cross_marquee.innerHTML=marqueecontent
actualwidth=document.getElementById("temp").offsetWidth
lefttime=setInterval("scrollmarquee()",20)
}
window.onload=populate
function scrollmarquee(){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-newspeed+"px"
else
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
}
with (document){
write('<div style="position:relative; top:655px; width:'+marqueewidth+'; height:'+marqueeheight+'; overflow:hidden">')
write('<div onMouseover="newspeed=pausespeed" onMouseout="newspeed=speed">')
write('<div …Run Code Online (Sandbox Code Playgroud) node.js ×3
arrays ×1
bouncycastle ×1
header ×1
html ×1
java ×1
javascript ×1
keystore ×1
marquee ×1
multer ×1
private-key ×1
signature ×1
sqlite ×1
upload ×1