问题描述: 在Angular中,当使用文件上传功能时,会出现接收到“C:\fakepath”并对不安全的URL进行过滤的问题。
解决方法:
onFileSelected(event) {
const file: File = event.target.files[0];
if (file) {
// 进行文件上传操作
}
}
onFileSelected(event) {
const file: File = event.target.files[0];
if (file) {
const url = URL.createObjectURL(file);
// 使用url来显示文件路径
}
}
通过以上步骤,你就可以解决Angular图片文件上传问题中接收到“C:\fakepath”并对不安全的URL进行过滤的问题了。
上一篇:Angular图片上传在Internet Explorer中无法工作,但在Google Chrome中可以工作。
下一篇:Angulartusharghoshbd-ngx-datatable-ERRORTypeError:arr.forEachisnotafunction