I want to change the name of my image in angular via the ng2-file-uploader and then pass it to my multer in my node.js.
Everything is working fine. I am able to receive the image and it is being stored in my upload directory on server side. It is just that I don't know where to change the image name. I tried it in the onCompleteItem method but nothing. Here is some code:
import { FileUploader, FileSelectDirective } from 'ng2-file-upload/ng2-file-upload';
@Component({
selector: 'name',
templateUrl: './some.html',
styleUrls: [./some.css]
})
export class ComponentName {
public uploader: FileUploader = new FileUploader({ url: "myurl", itemAlias: 'myPhoto' });
ngOnInit(){
this.uploader.onAfterAddingFile = (file) => {};
this.uploader.onCompleteItem = (item: any, response: any, status: any, headers: any) => {
//create my name
item.file.name = "my name"
alert('File uploaded');
};
this.uploader.uploadAll();
}
}
I just want to change the name so that I can store it in my database together with the other input values that I have.