零件 :
import { FileUploader } from 'ng2-file-upload/ng2-file-upload';
const URL = 'http://localhost:4200/api/ticketsystem/createticket';
public uploader: FileUploader = new FileUploader({ url: URL, itemAlias: 'file' });
this.uploader.onAfterAddingFile = (file) => { file.withCredentials = false; };
ngOnInIt(){
this.uploader.onCompleteItem = (item: any, response: any, status: any, headers: any) => {
console.log("ImageUpload:uploaded:", item, status, response);
};
this.uploader.onBeforeUploadItem = (item: any) => {
var ll = {
"severity": this.ticket.severity,
"subject": this.ticket.subject,
"description": this.ticket.description,
"priority": "High",
"status": "Open",
"owner": {
"id": this.userDetails[0].id
}
}
item.formData.push({ "ticket": JSON.stringify(ll) })
}
}
I have tried file upload using ng2-file-upload if i normally upload file means it can be upload but i need to send some input json object.
上面的代码 uploader.onBeforeLoadItem 方法我已经构建了我需要用上传器发送的 json 对象。在这里我需要帮助如何使用 formdata 对象发送我的输入值,我需要帮助