0
在下面的代碼中,我有兩個控制器,它們是upload/post和document/post,並且在API上傳輸時保存file.name時有點困難到秒,有時兩個不匹配,例如數據庫一個是file20170801053331.jpg
上傳的圖片將是file20170801053332.jpg
因爲,兩個不匹配,所以我打算將文件名轉移到上傳控制器,所以它會是相同的但是file.name不能被改變。如何在上傳之前更改dropzone中的File.Name
const req = request.post('http://localhost:8933/api/upload/post');
acceptedFiles.forEach(file => {
var now = new Date().toLocaleString('en-PH');
form.State = 1;
var cdate =dateFormat(now, "yyyymmddHHMMs")
var ext = file.name.split(".").slice(-1)[0];
var ext2 = file.name.split("."+ext).slice(0)[0];
var fileNames = (ext2+cdate+"." +ext);
form.Link=fileNames;
form.Name=file.name;
file.name = fileNames; // this is what im trying to do but it wasnt working
req.attach(file.name, file);
this.props.post('document/post', form);
});
req.end(callback);