Я передаю объект File
, который поступает из браузера (путем удаления) в функцию, подобную этой:
// .... logic here...
accept(file)
public static accept(file: File) {
console.log(file)
/* prints:
=> lastModified: 1555453309243
lastModifiedDate: Wed Apr 17 2019 01:21:49 GMT+0100 (GMT+01:00) {}
name: "test.txt"
path: "test.txt" --> as you can see there is a path variable in here.
size: 16
type: "text/plain"
webkitRelativePath: ""
__proto__: File
*/
console.log(file.name) // => prints 'test.txt'
console.log(file.size) // => prints '16'
console.log(file.path) // => !! error given. path does not exists in File object. Also IDE does not show this parameter in IDE autocomplete list.
}
Ошибка дана:
Property 'path' does not exist on type 'File'.ts(2339)
Почему File
не имеет параметра path
? Как я могу убедиться, что путь существует? Есть ли другой тип для File
? Это капля HTML5.
Если я сделаю это:
public static accept(file: any) {
alert(file.path);
}
Показывает относительный путь:
![path](https://i.stack.imgur.com/mTxYO.png)