【发布时间】:2019-03-08 12:21:10
【问题描述】:
我正在使用ngx-image-cropper 在我的角度应用程序中裁剪图像。我使用输出属性返回“文件”,即 (imageCroppedFile) 来获取裁剪后的图像。我需要裁剪后的图像有一个文件名,这样我就可以使用 name 属性遍历后端的文件,而默认情况下它是未定义的。我怎样才能给它一个名字? 我尝试了以下方法:在 FormData 上,
var formData:any = new FormData();
console.log('The number of files is '+files.length);//Logs the number of files is 1
for(var i=0; i<files.length;i++) {
formData.append("uploads[]", files[i].name, 'image'+i);
console.log('File name '+ i + ' ' +files[i].name);//Logs File name 0 undefined
}
关于裁剪触发的方法
imageCroppedFile(image: File) {
this.filesToUpload = [];
console.log('imageCroppedFile method '+image.name+ ' size is '+image.size);// Logs imageCroppedFile method undefined size is 380284
this.filesToUpload[0]=image;
console.log('The filesToUpload is '+this.filesToUpload[0].name);// Logs The filesToUpload is undefined
}
上传者在没有裁剪器的情况下工作。
【问题讨论】:
-
您在控制台日志图像中看到的所有属性是什么?
-
@Ritesh File(390053) {name: "blob", lastModified: 1538659450015, lastModifiedDate: Thu Oct 04 2018 16:24:10 GMT+0300 (East Africa Time), webkitRelativePath: "",大小:390053,…}
-
我也面临同样的问题
标签: angular image typescript cropper