我正在尝试通过选项,但不知道如何在服务器端处理它们。文件加载没有问题。我创建了一个表格:
webix.ui({
view: "form",
borderless: true,
elements: [
{view: "text", label: 'User', name: "user",invalidMessage:"User can not be empty"},
{view: "text", label: 'Name', name: "name",invalidMessage:"Name can not be empty"},
{view: "text", label: 'Email', name: "email",invalidMessage:"Incorrect e-mail address"},
{view: "text", label: 'Key', name: "key",invalidMessage:"Key can not be empty"},
{
view:"uploader",
id: "fileUploader",
value:"Upload key",
autosend:false,
upload:"api/upload"
},
{
view: "button", value: "Submit", click: function () {
var form = this.getParentView();
if (form.validate()){
var values = this.getParentView().getValues();
$$('fileUploader').send(function(res){
},{
fileName:values.user
});
}
}
}
],
rules:{
"user": webix.rules.isNotEmpty,
"name": webix.rules.isNotEmpty,
"email": webix.rules.isEmail,
"key": webix.rules.isNotEmpty
},
elementsConfig: {
labelPosition: "top"
}
});
我正在使用服务器 node.js
app.post('/api/upload/', function(req,res) {
fs.readFile(req.file.path, function (err, data) {
var newPath = __dirname + "/uploads/"+req.file.originalname;
fs.writeFile(newPath, data, function (err) {
res.send("ok");
fs.unlink( __dirname + "/uploads/"+req.file.filename);
});
});
}
);
或者是否有任何选项可以在 send() 之前更改名称?